29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Helper Functions 283<br />

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

The env function gets the value of an environment variable or returns a default value:<br />

.<br />

1 $env = env('APP_ENV');<br />

2<br />

3 // Return a default value if the variable doesn't exist...<br />

4 $env = env('APP_ENV', 'production');<br />

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

The event function dispatches the given event to its listeners:<br />

.<br />

1 event(new UserRegistered($user));<br />

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

The factory function creates a model factory builder for a given class, name, and amount. It can be<br />

used while testing or seeding:<br />

.<br />

1 $user = factory('App\User')->make();<br />

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

The method_field function generates an HTML hidden input field containing the spoofed value of<br />

the form’s HTTP verb. For example, using Blade syntax:<br />

.<br />

1 <br />

2 {!! method_field('delete') !!}<br />

3

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

Saved successfully!

Ooh no, something went wrong!