Fokrule
Fokrule

Reputation: 854

Why my return page is not working properly in laravel

This is my edit function

    public function edit($id)
    {   
    $notice = Notice::orderBy('id','desc')->paginate(5);
    $single_notice = Notice::find($id);
    $update_request = 'yes';
    return view('teacher.editnotice')->withSingle_notice($single_notice)-
    >withUpdate_request($update_request)->withNotices($notice);
    }

This is my update function

     public function update(Request $request, $id)
     {
    $update_notice = Notice::find($id);
    $previous_date = $update_notice->demoOrfinal;

    $teacher_id = 1;
    $update_notice->notice      = $request->notice;
    $update_notice->teacher_id  = $teacher_id;
       $update_notice->save();
       Session::flash('success','Notice Has Been Updated. Thanks 
       :-)');$notice 
       = Notice::orderBy('id','desc')->paginate(5);
       $id = "";
       $auth_permission = 'teacher';
       return view('teacher.notice')->withNotices($notice)-
       >withAuth_permission($auth_permission)->withId($id);
       }

When user will click for edit, edit function will send update request = 'yes' so that the update form div will visible. It is working perfect. But my problem is when user click update then update method should return to http://localhost:8000/notice/ but it is returning me to http://localhost:8000/notice/1(lastupdateteddataid) I am using laravel 5.4. My problem is why update function sending lats updated id after url. Can anyone please help me to solve this please.

Upvotes: 0

Views: 62

Answers (1)

RamAnji
RamAnji

Reputation: 470

instead of view try with route..i think it's work.

return redirect()->to('/notice')
                                ->withNotices($notice)-
           >withAuth_permission($auth_permission)->withId($id);

Upvotes: 2

Related Questions