Home > Back-end >  Laravel 8 route model binding not return ant record?
Laravel 8 route model binding not return ant record?

Time:05-24

I am using below code for route model binding but the binding variable does not return any value. MY ROUTE

Route::resource('offertypes', 'OfferTYpeController');

CONTROLLER CODE

    public function edit(OfferType $offerType)
    {
        dd($offerType);
        return view('admin.offer-types._form', compact('offerType'));
    }

BLADE FILE CODE

<td>
 <a href="{{ route('admin.offertypes.edit', $offerType->id) }}">{{ ucwords($offerType->title) }}</a>
</td>

RETURN VALUE my code returns this enter code here

CodePudding user response:

You have to use similar route parameter as your variable

Means your route should look like this

Route::get('edit/{offerType}', [SomeController::class, 'edit']);

Note: offerType is exactly same typed in parameter and in method variable.

Another issue could be if you have mistakenly commented this middleware in app\Http\Kernel.php

enter image description here

  • Related