Php 重定向到laravel中的上一页
我正在尝试重定向到具有Php 重定向到laravel中的上一页,php,laravel,Php,Laravel,我正在尝试重定向到具有id扩展名的前一个控制器,但我现在使用的函数不包含id扩展名。 我怎样才能再次重定向到该页面?我正在给控制器提供数据 public function comment($id, Request $request) { $user_name = $request->session()->get('user_name'); $ticket = Complaint::Where('id', '=', $id) ->SELECT('t
id
扩展名的前一个控制器,但我现在使用的函数不包含id
扩展名。我怎样才能再次重定向到该页面?我正在给控制器提供数据
public function comment($id, Request $request)
{
$user_name = $request->session()->get('user_name');
$ticket = Complaint::Where('id', '=', $id)
->SELECT('ticket_no')
->get();
foreach ($ticket as $tickets) {
$tik = $tickets['ticket_no'];
$comment = \DB::Select('SELECT comments.comment,comments.comment_by FROM comments JOIN complaints ON complaints.ticket_no=comments.complaint_id Where comments.comment_by=? or comments.comment_by=? AND comments.complaint_id=? ORDER BY comments.id desc limit 2', ["Admin", $user_name, $tik]);
return view('work.comment', compact('ticket', 'id', 'comment', 'user_name'));
}
}
public function getComment(Request $request, $id)
{
$complain_id = $request->input('ticket_no');
$user_name = $request->input('user_name');
$comment = $request->input('comment');
return redirect('ifa-dashboard/comment/', $id);
}
这是路线
Route::get('ifa-dashboard/comment/{id}','ComplainController@comment')->name('ifa.comment');
Route::POST('ifa-dashboard/getComment','ComplainController@getComment');
您可以使用
back()
方法将用户返回到上一页。例如:
return redirect()->back();