Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

php - 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.

}

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In store()

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

and in show() read it with

Session::get('data');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...