Skip to content

Instantly share code, notes, and snippets.

@Remonhasan
Last active April 16, 2024 09:35
Show Gist options
  • Save Remonhasan/f3c4f184d3c2f9be70cdb5d57d79b2d7 to your computer and use it in GitHub Desktop.
Save Remonhasan/f3c4f184d3c2f9be70cdb5d57d79b2d7 to your computer and use it in GitHub Desktop.
Laravel Route Model Binding
/**
* Show all categories
* Route Model Binding
* Like the below route you can access all of the categories
* Access route sample: http://localhost:8000/admin/category/1
* @param mixed $category
* @return void
*/
public function show(Category $category)
{
dd($category);
return view('admin.category.view', ['category' => $category]);
}
// Authentication Routes
Route::middleware(['auth'])->prefix('admin')->group(function () {
Route::prefix('category')->group(function () {
Route::get('/{category}', [CategoryController::class, 'show'])->name('category.show');
});
});
@Remonhasan
Copy link
Author

Remonhasan commented Apr 16, 2024

For more queries 👍
My Blog
Laravel Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment