Last active
April 16, 2024 09:35
-
-
Save Remonhasan/f3c4f184d3c2f9be70cdb5d57d79b2d7 to your computer and use it in GitHub Desktop.
Laravel Route Model Binding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Authentication Routes | |
Route::middleware(['auth'])->prefix('admin')->group(function () { | |
Route::prefix('category')->group(function () { | |
Route::get('/{category}', [CategoryController::class, 'show'])->name('category.show'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more queries 👍
My Blog
Laravel Documentation