当我尝试编辑和删除员工时,会显示错误。
删除
Missing argument 1 for App\Http\Controllers\Admin\CreateEmployeeController::deleteemployee()
用于编辑
Missing argument 1 for App\Http\Controllers\Admin\CreateEmployeeController::editemployee()
方法:
public function editemployee($id)
{
$employee = CreateEmployee::where('id',$id)->get();
return view('app.admin.employee.editemployee',compact('employee'));
}
public function updateemployee(Request $request)
{
CreateEmployee::where('id',$request->id)->update(array('username'=>$request->username,'area'=>$request->area_name));
Session::flash('flash_notification', array('level' => 'success', 'message' => 'channel details updated successfully'));
return Redirect::action('Admin\CreateEmployeeController@addemployee',array('id' => $request->id));
}
public function deleteemployee($id)
{
$employee = CreateEmployee::where('id',$id)->get();
return view('app.admin.employee.deleteemployee',compact('employee'));
}
public function deleteconfirms($id)
{
$employee = CreateEmployee::where('id',$id)->delete();
Session::flash('flash_notification', array('level' => 'success', 'message' => 'employee deleted successfully'));
return Redirect::action('Admin\CreateEmployeeController@addemployee');
}
答案 0 :(得分:1)
我可以看到您的方法deleteemployee
,deleteconfirms
和editemployee
期待id字段。
在您的路线中,您没有使用任何"路线参数" (详见Route Parameters)
因此,更改您的路线以包括路线参数,如下所示。其中id
代表employee_id
Route::get('edit-employee/{id}','CreateEmployeeController@editemployee');
Route::post('update-employee','CreateEmployeeController@updateemployee');
Route::get('delete-employee/{id}','CreateEmployeeController@deleteemployee');
Route::post('delete-confirms/{id}','CreateEmployeeController@deleteconfirms');