samedi 25 août 2018

My controller considers that my store id is the products id.

My controlller can't read that the 'sample' is a store and not a product. I have this Route on my web.php

    Route::get('{store}/products/{products}/edit', [
    'as'    => 'store.products.edit',
    'uses'  => 'ProductsController@edit',
    function($store) {
        $store = App\Models\Store::where('slug', $store)->firstOrFail();
    }
]);

and here is my ProductsController@edit

    public function edit($id)
{
    $product = Product::findOrFail($id);

    return view('view here', compact('product'));
}

when I run the url: http://127.0.0.1:8000/sample/products/022fe902-7f4d-4db1-b562-04a7eb9f5a68/edit

where sample is the {store} and 022fe902-7f4d-4db1-b562-04a7eb9f5a68 is the {product}

I get this error:

No query results for model [App\Models\Product] sample

in my query:

select * from products where products.uuid = 'sample' limit 1



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2P4Sn9k
via IFTTT

Aucun commentaire:

Enregistrer un commentaire