Answer the question
In order to leave comments, you need to log in
I display the resource route '/' in the blade, but when I switch to dw.app/2, it gives 404. If the route is '/list', for example, then everything works. How to fix?
Tried both url(), and action(), and route().
This is in blade:
<a href="{{ url('/', [$article->id]) }}">{{ $article->title }}</a>
Route::resource('/', 'ArticleController');
Route::get('/welcome', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', '[email protected]');
public function index()
{
$articles = Article::where('published', 1)->get();
return view('list', ['articles' => $articles]);
}
public function show($id)
{
$article = Article::with('comments')->find($id);
return view('article', ['article' => $article]);
}
Answer the question
In order to leave comments, you need to log in
Here are all the standard resource routes. The resource must have a name.
Should be corrected like this:
Route::resource('article', 'ArticleController');
route('article.show', ['id'=>$id]);
Route::get('/', function () {
return redirect()->route('article.index');
});
Route::get('/{id}', ['uses' => '[email protected]']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question