簡體   English   中英

在laravel中重定向到上一頁

[英]redirecting to previous page in laravel

我正在嘗試重定向到具有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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM