Laravel
Laravel
Laravel
Urmil Pawaskar
Roll No. 59
Routes
With Id
With Name
Routes
Blde.php files
OUTPUT
MiddleWare
Register
Welcome
WebGuard.php
Web.php
OUTPUT
Array
@php
$record = array(
array("id"=>1, "Name"=>"Urmil", "Salary"=>50000),
array("id"=>2, "Name"=>"Hello", "Salary"=>55000),
array("id"=>3, "Name"=>"Hi", "Salary"=>57000),
);
@endphp
@if(!empty($record))
<h1>Records:</h1>
<ul>
@foreach($record as $item)
<li>ID: {{ $item['id'] }}, Name: {{ $item['Name'] }}, Salary: {{ $item['Salary']
}}</li>
@endforeach
</ul>
@else
<p>No records found.</p>
@endforelse
Web.php
Output
URL GENERATION
STEP-I
url.blade.php
STEP-II
web.php
OUTPUT:
EVENTS AND LISTENERS
Code:
Step1:
EventServiceProvider.php:
'App\Event\Purchase'=>[
'App\Listeners\Notify'
],
Step2:
Then in cmd:
Step3:
Purchase.php :
<?php
namespace App\Event;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class Purchase
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message=$message;
}
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
Step4:
Notify.php :
<?php
namespace App\Listeners;
use App\Event\Purchase;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class Notify
public function __construct()
{
}
public function handle(Purchase $event)
{
print_r($event->message);
echo "<script>alert('event has been listened !!');</script>";
exit;
}
}
Step5:
EventController.php :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Event\Purchase;
Step6:
Web.php :
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('go',[App\Http\Controllers\EventController::class,'test']);
Output:
Encryption in laravel
Encryption
Output
Decryption
Password Hashing
Php artisan migrate rollback
Insert
Show
Update
Updated
Registration