重定向错误异常数组到字符串转换Laravel 8
redirect error exception array to string conversion Laravel 8
我正在尝试将我的删除功能重定向回具有参数组的索引页面。但它一直向我抛出错误异常数组到字符串转换。
这是我在 MonitorController.php
上的索引函数
public function index(Team $team)
{
$team = Team::where('id',$team->id)->first();
$objective = Objective::with('keyresult')
->where('team_id',$team->id)
->get();
$objective = Objective::with('task')
->where('team_id',$team->id)
->get();
$objective = Objective::with('deadline')
->where('team_id',$team->id)
->get();
return view('/sistem/monitor/index', compact('objective','team'));
}
这是我在同一个文件中的删除功能 MonitorController.php
public function destroy(Team $team, Objective $objective, Deadline $deadline)
{
//for deleting objective
Objective::destroy($objective->id);
Deadline::destroy($deadline->id);
return redirect()->action([MonitorController::class, 'index',['team'=>$team]])->with('status', 'Objective Successfully Deleted');
}
这里是索引和销毁路由
Route::get('/sistem/monitor/index/{team}', 'MonitorController@index');
Route::delete('/sistem/monitor/objective/details/{team}/{objective}', 'MonitorController@destroy');
Route::get('/sistem/monitor/index/{team}', 'MonitorController@index')->name('sistem.monitor.index');
在你的控制器中:
return redirect()->route('sistem.monitor.index', ['team' => $team])->with('status', 'Objective Successfully Deleted');
在路由中,您应该始终传递路由名称。在 web.php 上的路线中,您可以通过以下方式指定自定义路线名称:->name('sistem.monitor.index')
我正在尝试将我的删除功能重定向回具有参数组的索引页面。但它一直向我抛出错误异常数组到字符串转换。 这是我在 MonitorController.php
上的索引函数public function index(Team $team)
{
$team = Team::where('id',$team->id)->first();
$objective = Objective::with('keyresult')
->where('team_id',$team->id)
->get();
$objective = Objective::with('task')
->where('team_id',$team->id)
->get();
$objective = Objective::with('deadline')
->where('team_id',$team->id)
->get();
return view('/sistem/monitor/index', compact('objective','team'));
}
这是我在同一个文件中的删除功能 MonitorController.php
public function destroy(Team $team, Objective $objective, Deadline $deadline)
{
//for deleting objective
Objective::destroy($objective->id);
Deadline::destroy($deadline->id);
return redirect()->action([MonitorController::class, 'index',['team'=>$team]])->with('status', 'Objective Successfully Deleted');
}
这里是索引和销毁路由
Route::get('/sistem/monitor/index/{team}', 'MonitorController@index');
Route::delete('/sistem/monitor/objective/details/{team}/{objective}', 'MonitorController@destroy');
Route::get('/sistem/monitor/index/{team}', 'MonitorController@index')->name('sistem.monitor.index');
在你的控制器中:
return redirect()->route('sistem.monitor.index', ['team' => $team])->with('status', 'Objective Successfully Deleted');
在路由中,您应该始终传递路由名称。在 web.php 上的路线中,您可以通过以下方式指定自定义路线名称:->name('sistem.monitor.index')