mardi 28 août 2018

Laravel url is getting the uuid instead of the slug

so, I have this button located at products.index.blade.php

<a href="" class="btn btn-default">
    <i class="fa fa-plus"></i> Create New Product
</a>

in which, when you click it, it should redirect to url: http://127.0.0.1:8000/sample/products/create where 'sample' is the slug. but instead, it redirects to: http://127.0.0.1:8000/36bf3d40-8cb7-11e8-9f9e-5b6a2e94b49b/products/create where instead of the slug, the uuid is there.

my query shows this:

select * from `stores` where `slug` = '36bf3d40-8cb7-11e8-9f9e-5b6a2e94b49b' limit 1

Here is my web.php

    Route::get('{store}/products/create', [
    'as'    => 'products.create',
    'uses'  => 'ProductsController@create',
]);

Route::post('{store}/products/create', [
    'as'    => 'products.store',
    'uses'  => 'ProductsController@store',
]);

and my ProductsController@create:

    public function create($store)
{
    $store = Store::where('slug', $store)->firstOrFail();
    return view('devoptions.products.create', compact('store'));
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire