J
J
Jedi2018-05-12 09:57:27
Laravel
Jedi, 2018-05-12 09:57:27

Why is Slug not working?

Err: Sorry, the page you are looking for could not be found.
Route: /posts/hello-world
What could be wrong?
web.php How to fix? :(
Route::resource('/posts', 'PostController');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tesla, 2018-05-13
@PHPjedi

If the database checks id instead of slug, then you need to specify in the model the key by which the search in the database should be performed. getRouteKeyName()

U
UksusoFF, 2018-05-12
@UksusoFF

You don't need packages. Write this functionality yourself. Laravel has everything for this - route model binding and str_slug ().
Then it will immediately become clear what is wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question