多个laravel 5.5路由方法显示错误

时间:2018-03-12 10:14:00

标签: php laravel

我在web.php中有三条路线

test_df = df.copy(deep = True)
ax = test_df[(test_df.index.year ==2017) ]['error'].plot(kind="bar")
plt.figure(figsize=(15,8))

# Make a list of empty myLabels
myLabels = ['']*len(test_df.index)

# Set labels on every 20th element in myLabels
myLabels[::20] = [item.strftime('%Y - %m') for item in test_df.index[::20]]
ax.xaxis.set_major_formatter(ticker.FixedFormatter(myLabels))
plt.gcf().autofmt_xdate()

# Tilt the labels
plt.setp(ax.get_xticklabels(), rotation=30, fontsize=10)
plt.show()

但是当我点击相应的菜单链接时,它会显示第一条路线,其他路线则无法工作。 请问我做错了什么,我需要帮助。 这是控制器的代码 用于托儿所控制器

Route::get('/secondary', 'SecondaryController@show');
Route::get('/primary', 'PrimaryController@show');
Route::get('/nursery', 'NurseryController@show');
主控制器的

public function show($slugs){
     $NurseryPages = NurseryPages::findByURL($slugs);
     return view('nursery.show', ['NurseryPages' =>$NurseryPages]);
}

用于辅助控制器

 public function show($slugs){
     $PrimaryPages = PrimaryPages::findByURL($slugs);
     return view('primary.show', ['PrimaryPages' =>$PrimaryPages]);
}

它只适用于托儿所部分,但在其他部分则显示错误:尝试获取非属性对象并将我引回到nursery.show文件 这是错误消息

public function show($slugs)
{
     $SecondaryPages = SecondaryPages::findByURL($slugs);
     return view('secondary.show', ['SecondaryPages' =>$SecondaryPages]);
}

尝试获取非对象的属性(查看:C:\ xampp \ htdocs \ acadapp \ resources \ views \ secondary \ show.blade.php)

 ErrorException (E_ERROR)

1 个答案:

答案 0 :(得分:0)

我认为您需要更改路线,如:

Route::get('/secondary/{slug}', 'SecondaryController@show');
Route::get('/primary/{slug}', 'PrimaryController@show');
Route::get('/nursery/{slug}', 'NurseryController@show');