In Laravel, you can send a variable to a Blade route by using the route function with a second parameter as an array of data. For example:
Route::get('/profile/{id}', function($id) {
return view('profile', ['user_id' => $id]);
});
In this example, we are passing a variable 'userid' to the profile view with the value of the ID parameter from the route. In the Blade template, you can access the value of the 'userid' variable using the {{ }} syntax:
<h1>User Profile</h1>
<p>User ID: {{ $user_id }}</p>
Asked: 2021-12-11 11:00:00 +0000
Seen: 7 times
Last updated: Jun 07 '21