我正在使用 Laravel 7 构建餐厅系统我制作了前往特定路线的表格,我得到了名称路线,但标题显示错误
经理视图
<form method="post" action="{{route('admin.distroyDish')}}" >
@csrf
<div class="form-group">
<select class="form-control" name="dish">
@for ($i = 0 ; $i < count($InetialData['dish']); $i++))
<option value="{{ $InetialData['dish'][$i]->id }}">
{{ $InetialData['dish'][$i]->name }}
</option>
@endfor
</select>
</div>
<input type="submit" name="delete_dish" value="Delete" class="btn btn-danger">
<br>
</form>
网络路由文件
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/manager', 'ManagerController@dashboard');
Route::post('/manager', 'ManagerController@addItem');
Route::get('/manager/{id}', 'ManagerController@deleteTable')->name('admin.deleteTable');
Route::post('/manager', 'ManagerController@destroyDish')->name('admin.distroyDish');
Route::post('/manager', 'ManagerController@addIngrediant')->name('admin.addIngrediant');
Route::get('/kitchen', 'KitchenController@index')->name('kitchen.home');
Route::get('/kitchen/{id}', 'KitchenController@submitDish')->name('kitchen.submit.dish');
Route::post('/kitchen', 'KitchenController@addIngrediant')->name('kitchen.addIngrediant');
管理器控制器
private function initData()
{
$InetialData = array(
'category' => DB::table('Category')->get(),
'dish' => DB::table('Items')->get(),
'users' => DB::table('users')->get(),
'Ingrediant' => DB::table('Ingrediant')->get(),
'IngrediantHistory' => DB::table('IngrediantHistory')->get()
);
return $InetialData;
}
public function destroyDish(Request $request)
{
DB::table('Items')
->where('id', '=', $request->dish)
->delete();
return redirect('/manager')->with('InetialData' , $this->initData());
}
像厨房这样的其他路线正在工作,为什么这条路线不起作用?