TuffRivers
6 months ago
1082
5
Laravel

Route Model Binding with Resource Routes?

Posted 6 months ago by TuffRivers

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)         
       
   
    }

Please sign in or create an account to participate in this conversation.