First of all, shouldn't it be resource instead of Route::resources([?
You get your answer there-
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can i inject the model data into my routes with Route::resource routes? Is it automatically available because the resource creates /route/{id} ? I tried type hinting in my controller but that doesnt seem to work, it returns an empty model.
My Route
Route::group(['middleware' => 'jwt.auth'], function() {
Route::resources([
'cards' => 'api\Card\CardController'
]);
});
My controller
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Card $id)
{
//how to access? everything i try returns blank
// print_r($id)
}
look at the php artisan route:list
You will see the routes described as /cards/{card}
You must accept the model in your controller as $card and not $id
Please or to participate in this conversation.