vendredi 8 septembre 2017

how to store array of data in Session and retrieve it Laravel?

I was trying to store some data in session through ajax. Means from Ajax request i would get the product_id and it put it inside product array through Session. And I want to retrieve every session array data.

Every Ajax request product_id will be stored into Session Array: // for storing $products into session following controller .But it stored only last one not the previous request

public function postEnquote(Request $request)
    {
       $product = Product::where('id',$request->Input(['product_id']))->first();
       Session::put('product', $product);
    }

// For retrieving every session data i used following one, but doesn't work properly means i couldn't get every session data..

  public function enquoteList()
    {
      foreach(Session::get('product') as $test)
      {
         var_dump($test->id);
      }

     }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire