Missing required parameters in route Laravel 5.7












0














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.










share|improve this question






















  • 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
















0














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.










share|improve this question






















  • 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














0












0








0







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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












1 Answer
1






active

oldest

votes


















0














You should try this



{{ route('admin.view-news', $id) }}


Instead of



{{ route('admin.view-news') }}





share|improve this answer





















  • thank you, i already fixed it :)
    – Čendi
    Nov 21 '18 at 15:45











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
});


}
});














draft saved

draft discarded


















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









0














You should try this



{{ route('admin.view-news', $id) }}


Instead of



{{ route('admin.view-news') }}





share|improve this answer





















  • thank you, i already fixed it :)
    – Čendi
    Nov 21 '18 at 15:45
















0














You should try this



{{ route('admin.view-news', $id) }}


Instead of



{{ route('admin.view-news') }}





share|improve this answer





















  • thank you, i already fixed it :)
    – Čendi
    Nov 21 '18 at 15:45














0












0








0






You should try this



{{ route('admin.view-news', $id) }}


Instead of



{{ route('admin.view-news') }}





share|improve this answer












You should try this



{{ route('admin.view-news', $id) }}


Instead of



{{ route('admin.view-news') }}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 13:22









Kiran Patel

544




544












  • 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




thank you, i already fixed it :)
– Čendi
Nov 21 '18 at 15:45


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]