lundi 29 août 2016

Laravel 5.1 Passing data (controller -> view)

I'm new to Laravel, I want to understand what is the best approach to share values from controllers to views: I have found few ways of doing it :

  1. view()->share('variable_name',$value);
  2. session(['variable_name'=>$value]);
  3. return view('viewname')->with('variable_name'=>$value);

Is there any difference between these ways? Also, is it a good practice to share data from the model(from design point of view)?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire