Missing required parameters in route Laravel 5.7
up vote
0
down vote
favorite
what could be wrong with this:
route
Route::get('admin/view-news/{id}', 'AdminNewsController@show')->name('admin.view-news');
controller
public function index()
{
$news = News::all();
return view('admin.news.news');
}
public function show($id)
{
$news = News::Find($id);
return view('admin.news.view_news')->with('news', $news);
in controller i tried this as well:
`return view('admin.news.view_news', ['news' => News::findOrFail($id)])`;
view
{{ route ('admin.view-news') }}
An important note is, almost the same thing for users is working:
route:
Route::get('/user/{id}', 'UsersController@show');
controller:
public function index()
{
$users = User::orderBy('name', 'asc')->paginate(30);
return view('admin.users.users')->with('users', $users);
}
public function show($id)
{
$user = User::find($id);
return view('admin.users.view_user')->with('user', $user);
}
The error is:
Missing required parameters for [Route: admin.view-news] [URI: admin/view-news/{id}].
What am i missing here, how im not getting the id, and in users controller i do, with almost the same code? Thanks.
routes laravel-5.7
add a comment |
up vote
0
down vote
favorite
what could be wrong with this:
route
Route::get('admin/view-news/{id}', 'AdminNewsController@show')->name('admin.view-news');
controller
public function index()
{
$news = News::all();
return view('admin.news.news');
}
public function show($id)
{
$news = News::Find($id);
return view('admin.news.view_news')->with('news', $news);
in controller i tried this as well:
`return view('admin.news.view_news', ['news' => News::findOrFail($id)])`;
view
{{ route ('admin.view-news') }}
An important note is, almost the same thing for users is working:
route:
Route::get('/user/{id}', 'UsersController@show');
controller:
public function index()
{
$users = User::orderBy('name', 'asc')->paginate(30);
return view('admin.users.users')->with('users', $users);
}
public function show($id)
{
$user = User::find($id);
return view('admin.users.view_user')->with('user', $user);
}
The error is:
Missing required parameters for [Route: admin.view-news] [URI: admin/view-news/{id}].
What am i missing here, how im not getting the id, and in users controller i do, with almost the same code? Thanks.
routes laravel-5.7
In your view{{ route ('admin.view-news',$news->id) }}you should provide the some id to route
– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
what could be wrong with this:
route
Route::get('admin/view-news/{id}', 'AdminNewsController@show')->name('admin.view-news');
controller
public function index()
{
$news = News::all();
return view('admin.news.news');
}
public function show($id)
{
$news = News::Find($id);
return view('admin.news.view_news')->with('news', $news);
in controller i tried this as well:
`return view('admin.news.view_news', ['news' => News::findOrFail($id)])`;
view
{{ route ('admin.view-news') }}
An important note is, almost the same thing for users is working:
route:
Route::get('/user/{id}', 'UsersController@show');
controller:
public function index()
{
$users = User::orderBy('name', 'asc')->paginate(30);
return view('admin.users.users')->with('users', $users);
}
public function show($id)
{
$user = User::find($id);
return view('admin.users.view_user')->with('user', $user);
}
The error is:
Missing required parameters for [Route: admin.view-news] [URI: admin/view-news/{id}].
What am i missing here, how im not getting the id, and in users controller i do, with almost the same code? Thanks.
routes laravel-5.7
what could be wrong with this:
route
Route::get('admin/view-news/{id}', 'AdminNewsController@show')->name('admin.view-news');
controller
public function index()
{
$news = News::all();
return view('admin.news.news');
}
public function show($id)
{
$news = News::Find($id);
return view('admin.news.view_news')->with('news', $news);
in controller i tried this as well:
`return view('admin.news.view_news', ['news' => News::findOrFail($id)])`;
view
{{ route ('admin.view-news') }}
An important note is, almost the same thing for users is working:
route:
Route::get('/user/{id}', 'UsersController@show');
controller:
public function index()
{
$users = User::orderBy('name', 'asc')->paginate(30);
return view('admin.users.users')->with('users', $users);
}
public function show($id)
{
$user = User::find($id);
return view('admin.users.view_user')->with('user', $user);
}
The error is:
Missing required parameters for [Route: admin.view-news] [URI: admin/view-news/{id}].
What am i missing here, how im not getting the id, and in users controller i do, with almost the same code? Thanks.
routes laravel-5.7
routes laravel-5.7
asked Nov 19 at 13:22
Čendi
415
415
In your view{{ route ('admin.view-news',$news->id) }}you should provide the some id to route
– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06
add a comment |
In your view{{ route ('admin.view-news',$news->id) }}you should provide the some id to route
– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06
In your view
{{ route ('admin.view-news',$news->id) }} you should provide the some id to route– Omar Abdullah
Nov 19 at 14:40
In your view
{{ route ('admin.view-news',$news->id) }} you should provide the some id to route– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
add a comment |
up vote
0
down vote
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
add a comment |
up vote
0
down vote
up vote
0
down vote
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
answered Nov 20 at 13:22
Kiran Patel
544
544
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
add a comment |
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
thank you, i already fixed it :)
– Čendi
Nov 21 at 15:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375583%2fmissing-required-parameters-in-route-laravel-5-7%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In your view
{{ route ('admin.view-news',$news->id) }}you should provide the some id to route– Omar Abdullah
Nov 19 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 at 14:40
i did, News:find($id) is not working for some reason, while User::find($id) does work, in show function in both controllers.
– Čendi
Nov 19 at 15:06