I have a model called Dbtable which isn't injected when used like this:
public function showEditDbTableForm(Request $request, DbTable $table)
{
}
it only works when I do this:
public function showEditDbTableForm(Request $request, $id)
{
$table = DbTable::find( $id );
}
Same thing happens even when I rename DbTable to DbTble
P.S.: please don't be rude with me as I'm new to Laravel framework
For Implicit Route Model Binding you need to make sure the parameter in the method signature has the same name as the route parameter you want to bind.
Route::get('widgets/{widget}', 'WidgetsController@show');
public function show(Widget $widget)
Laravel automatically resolves Eloquent models defined in routes or controller actions whose type-hinted variable names match a route segment name.
In RouteServiceProvider class add
public function boot()
{
parent::boot();
Route::model('db-table', App\DbTable::class);
// db-table correspond your rout parameter
}
see official documentation https://laravel.com/docs/5.5/routing Explicit Binding section