Is there any difference when i am passing POST data to blade template, between this :
return View::make('postdata')->with('postData', Input::all());
and this one?
return View::make('postdata', array('postData'=> Input::all()));
Or both are the same and i should go on with shorter syntax?
Best How To :
As it has already been said both will do the same. The difference is, that by chaining methods to the
View object you will be able to instantiate and manipulate a
View object while chaining data to it, before it will be eventually returned as response. In real life that happens pretty rarely, so that for the most purposes both will achieve the same.
But for passing Input data back to the view there is an even simpler method:
withInput() all your previous Input will be passed to the view again. You would then access it by using
Input::old('email') in your View for example.
Make sure that you call
Input::flash() in your controller method first before using
Input::old() pulls data out of the Session Flashdata which makes the call to the mentioned method necessary. - Thanks to pc-shooter for mentioning.