How to send data using redirect with Laravel

前端 未结 3 1536
借酒劲吻你
借酒劲吻你 2020-12-05 23:41

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) pag

3条回答
  •  半阙折子戏
    2020-12-06 00:08

    A simple redirect using helper functions.

    So you don't need to set use Redirect nor use Session in your Controller.

    After you're done processing something in your Controller, insert:

    return redirect()->route( 'clients.show' )->with( [ 'id' => $id ] );
    

    To retrieve the variable 'id' in route 'clients.show', use:

    // in PHP
    $id = session()->get( 'id' );
    
    // in Blade
    {{ session()->get( 'id' ) }}
    

提交回复
热议问题