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.

Release Notes 10<br />

14 * @param string $role<br />

15 * @return mixed<br />

16 */<br />

17 public function handle($request, Closure $next, $role)<br />

18 {<br />

19 if (! $request->user()->hasRole($role)) {<br />

20 // Redirect...<br />

21 }<br />

22<br />

23 return $next($request);<br />

24 }<br />

25<br />

26 }<br />

Middleware parameters may be specified when defining the route by separating the middleware<br />

name and parameters with a :. Multiple parameters should be delimited by commas:<br />

1 Route::put('post/{id}', ['middleware' => 'role:editor', function ($id) {<br />

2 //<br />

3 }]);<br />

For more information on middleware, check out the middleware documentation.<br />

Testing Overhaul<br />

The built-in testing capabilities of Laravel have been dramatically improved. A variety of new<br />

methods provide a fluent, expressive interface for interacting with your application and examining<br />

its responses. For example, check out the following test:<br />

1 public function testNewUserRegistration()<br />

2 {<br />

3 $this->visit('/register')<br />

4 ->type('Taylor', 'name')<br />

5 ->check('terms')<br />

6 ->press('Register')<br />

7 ->seePageIs('/dashboard');<br />

8 }

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

Saved successfully!

Ooh no, something went wrong!