Monday, March 6, 2017

[SOLVED]Laravel 5.4 implicit route model binding with resource returns empty object

I'm stuck on a very odd issue with laravel's route model binding.
Using a route resource:
Route::resource('vendors', 'VendorController');

The route for editing an entry is the following:
GET|HEAD | admin/vendors/{vendor}/edit | vendors.edit | App\Http\Controllers\VendorController@edit | web,auth.admin

So from my understanding of implicit route model binding, the vendor attribute should allow accessing the object directly.
In my Controller function I can get the actual id with no problem. But when I try to get the vendor object, the result is empty. No 404, but just an empty result, making the template fail with "Undefined variable: vendor".
public function edit(Vendor $vendor)
{
    dd($vendor);
    return view('admin.vendor.edit', compact($vendor));
}

Can anybody point me in the right direction?


via asto

Advertisement