Ad
Not Getting Id From URL In Laravel 6
I am very new in laravel and trying to get id from URL example.com/cmsedit/3 but failing.
My routes:-
Route::get('cmsedit/{id}', function($id)
{
return view('admin.cmsed');
});
when I am trying to get an ID in my view file
<?PHP echo $id ?>
It says Undefined variable: id
and if I am using $request->id
it is also throwing an error Undefined variable: request
Laravel version = 6
Ad
Answer
You should return the given ID from Router's callback:
Route::get('cmsedit/{id}', function($id) {
return view('admin.cmsed', ['id' => $id]);
});
or,
Route::get('cmsedit/{id}', function($id) {
return view('admin.cmsed', compact('id'));
});
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad