mercredi 4 septembre 2019

My Slug Route Return 404 in my Laravel Code

I have stored my slug in my database but i get 404 Not found when i load the url

NewsController.php

public function show(News $news, $slug)
    {   

        return view('news.single', compact('news'));
    }

News.php

protected static function boot() {
    parent::boot();

    static::creating(function ($news) {
        $news->slug = Str::slug($news->subject);
    });
}

Route

Route::get('/news/{slug}', 'NewsController@show')->name('news.show');

I am getting 404 not found if load e.g localhost:8000/news/sample-post



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire