Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send data using redirect with Laravel

I developed an API to show a pop up message when the page loaded.

Not all the pages use the pop up API. For example, if the user go to the show($id) page, that doesn't required the pop up api to fire. but in some special cases, I need the pop up to be fired.

Here is my code, ** this code is just to illustrate my point, not an actual working code**

public function store(){     validating the input      saving them      $id = get the id      return Redirect::route('clients.show, $id') } 

and in the show function I do this:

public function show($id){    $client =Client::find($id)    return View::make('clients.profife')->with(array(    'data' => $client )) 

My question

Is there a way so I can send a data from the store function to the show function using Redirect::route ? and then in the show function, I check if this show function, I check if this data has been sent of what and then I decide whether to fire the pop up api or not.

}

like image 691
Anastasie Laurent Avatar asked Aug 01 '14 10:08

Anastasie Laurent


People also ask

How do you pass a variable redirect in Laravel?

You can use the compact function to pass it to your view and reference it by the name. Show activity on this post. return view('viewfile')->with('card',$card)->with('another',$another); You can send data using redirect method.

How pass data redirect?

Click Action > URL Redirect. Give your action an internal title (something that makes sense to you in the survey). Enter the link to the site in the URL field. Scroll to the Fields To Pass and select the question, hidden value, or URL Variables you would like to pass in the Question to Send dropdown.

How do I redirect in Laravel?

Redirecting to Controller Actions Not only named route but we can also redirect to controller actions. We need to simply pass the controller and name of the action to the action method as shown in the following example. If you want to pass a parameter, you can pass it as the second argument of the action method.

How do I move data from one page to another in Laravel?

You can send an ID (variable value) to another page in Laravel using the route method in the anchor tag in the view file by passing the variable to it. You have to just pass data from route to controller and after controller to another view page.


1 Answers

In store()

return Redirect::route('clients.show, $id')->with( ['data' => $data] ); 

and in show() read it with

Session::get('data'); 
like image 189
peter.babic Avatar answered Oct 04 '22 04:10

peter.babic