When i visit to my.site/api/genre/slug-name
In route/api.php
:
Route::prefix('genre')->group(function () {
Route::get('/{slug}', [FilmController::class,'getFilmByGenre'])->name('api_genre_film');
});
In getFilmByGenre
:
public function getFilmByGenre(Request $request, string $slug)
{
dd($slug, $request->slug, $request->get("slug")); // "slug-name" - "slug-name" - null
}
Can anyone please explain to me the difference when using $slug
, $request->slug
and $request->get("slug")
?
I’m using laravel 10.x. Thanks for your help!
New contributor
elas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.