【发布时间】:2016-12-02 20:49:50
【问题描述】:
我收到了上述问题中提到的错误,这是我的方法代码
function customHeader($id, $user_id, Request $request){
if ($user_id == Auth::user()->id || Auth::user()->is_admin){
$method = $request->method();
// To show View
if($request->isMethod('GET')){
} // Create
elseif($request->isMethod('POST')){
// Delete
} elseif($request->isMethod('Delete')){
//Delete single
} else{
return redirect()->back();
}
}
只有在用户需要删除记录时才需要上面的函数参数 id .. 我认为错误是由于该 id 而我需要 id 变量。如果我删除该 $id 它适用于创建我如何修复该错误
路线如下
Route::any('/setting/custom-header/{id?}', 'SettingController@customHeader');
【问题讨论】:
-
为什么需要 user_id 变量?
-
因为我在 url 中有 id .. 如果我不使用这个用户可以通过编辑进入其他表单