I have three routes in web.php
Route::get('/secondary', 'SecondaryController@show');
Route::get('/primary', 'PrimaryController@show');
Route::get('/nursery', 'NurseryController@show');
But when i click on the respective menu link, it presents the first route, others just wont work. pls what am i doing wrongly, i need help. this is code for the controllers for the nursery controller
public function show($slugs){
$NurseryPages = NurseryPages::findByURL($slugs);
return view('nursery.show', ['NurseryPages' =>$NurseryPages]);
}
for the primary controller
public function show($slugs){
$PrimaryPages = PrimaryPages::findByURL($slugs);
return view('primary.show', ['PrimaryPages' =>$PrimaryPages]);
}
for the secondary controller
public function show($slugs)
{
$SecondaryPages = SecondaryPages::findByURL($slugs);
return view('secondary.show', ['SecondaryPages' =>$SecondaryPages]);
}
it will only work well for the nursery section, but on others it displays error: trying to get object of non-property and refers me back to the nursery.show file this is the error msg
ErrorException (E_ERROR)
Trying to get property of non-object (View: C:\\xampp\\htdocs\\acadapp\\resources\\views\\secondary\\show.blade.php)
<?php echo $__env->make('inc.secondary.navbar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<br/><br/><br/>
<b><h3><?php echo $SecondaryPage->title; ?></b></h3>
<?php echo $SecondaryPage->body; ?>
</div>
</div>
</div>
<?php echo $__env->make('inc.secondary.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
I think you need to change your route like:
Route::get('/secondary/{slug}', 'SecondaryController@show');
Route::get('/primary/{slug}', 'PrimaryController@show');
Route::get('/nursery/{slug}', 'NurseryController@show');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.