jeudi 22 août 2019

Resource Controller methods with model as parameter not working

As in the basic Laracasts.com tutorial (Laracast 5.7 from scratch) I'm trying to use the following methods public function show(prototypes $prototypes) parameter to construct a view. However my view is created correctly but $prototypes is null.

The route works well(/prototypes/1/edit) and I ensured that a prototype object with the id 1 exists. I found some older solution which stated to use something like (integer $id) as parameter but this leads to some more code. It should work like this:

Controller:

public function edit(prototypes $prototypes)
    {
        //
        return view('prototypes.edit', compact('prototypes'));
    }

According to Laracast From Scratch this should work.

Do you know how I could fix this?

What mechanism is behind this that the prototypes.edit method knows how to use the correct parameter?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire