Reputation: 73
Im new to laravel. I'm creating this project and here, after i save my data, i want to return to my previous state.
public function storeData(Request $request){
// dd($request->all());
$this->validate($request,[
'Province'=>'required',
'District' => 'required|max:100|min:3',
'Electrorate' => 'required|max:100|min:3',
'PollingBooth' => 'required|max:100|min:3',
'issueTitle' => 'required|max:160|min:3',
'issueDetails'=>'required|max:500|min:30',
'issueCategory'=>'required'
]);
$pollingbooth = new pollingbooth;
$pollingbooth->Province=$request->Province;
$pollingbooth->District=$request->District;
$pollingbooth->Electrorate=$request->Electrorate;
$pollingbooth->PollingBooth=$request->PollingBooth;
$pollingbooth->issueTitle=$request->issueTitle;
$pollingbooth->issueDetails=$request->issueDetails;
$pollingbooth->issueCategory=$request->issueCategory;
$pollingbooth->save();
$pollingBoothNames=pollingbooth::all();
// dd ($pollingBoothNames);
return view('issues')->with('pollingBoothNamez',$pollingBoothNames);
// return redirect()->back();
}
above is my code. i tried
return view('issues')->with('pollingBoothNamez',$pollingBoothNames)->redirect()->back();
but no luck. what should i do here? Im having the same problem with updating a "Issue" as well.
Upvotes: 0
Views: 1427
Reputation: 34678
This will work :
return redirect()->back()->with(''pollingBoothNamez', $pollingBoothNames);
Upvotes: 2
Reputation: 636
return redirect()->back();
or
return Redirect::to('your-route-url');
Upvotes: 1
Reputation: 8927
You can simply call the route like this return redirect('home/dashboard');
Upvotes: 1