Missing required parameters in route 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
add a comment |
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 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 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 '18 at 15:06
add a comment |
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 '18 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 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 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 '18 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 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 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 '18 at 15:06
In your view
{{ route ('admin.view-news',$news->id) }}
you should provide the some id to route– Omar Abdullah
Nov 19 '18 at 14:40
In your view
{{ route ('admin.view-news',$news->id) }}
you should provide the some id to route– Omar Abdullah
Nov 19 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 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 '18 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 '18 at 15:06
add a comment |
1 Answer
1
active
oldest
votes
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
add a comment |
You should try this
{{ route('admin.view-news', $id) }}
Instead of
{{ route('admin.view-news') }}
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
add a comment |
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 '18 at 13:22
Kiran Patel
544
544
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
add a comment |
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45
thank you, i already fixed it :)
– Čendi
Nov 21 '18 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 '18 at 14:40
or compare it with user view
– Omar Abdullah
Nov 19 '18 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 '18 at 15:06