06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Helper Functions 391<br />

response() {#collection-method}<br />

The response function creates a response instance or obtains an instance of the response factory:<br />

1 return response('Hello World', 200, $headers);<br />

2<br />

3 return response()->json(['foo' => 'bar'], 200, $headers);<br />

session() {#collection-method}<br />

The session function may be used to get / set a session value:<br />

1 $value = session('key');<br />

You may set values by passing an array of key / value pairs to the function:<br />

1 session(['chairs' => 7, 'instruments' => 3]);<br />

The session store will be returned if no value is passed to the function:<br />

1 $value = session()->get('key');<br />

2<br />

3 session()->put('key', $value);<br />

value() {#collection-method}<br />

The value function’s behavior will simply return the value it is given. However, if you pass a Closure<br />

to the function, the Closure will be executed then its result will be returned:<br />

1 $value = value(function() { return 'bar'; });

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!