03.12.2015 Views

laravel4cookbook

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

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

Authentication 23<br />

1 @extends("layout")<br />

2 @section("content")<br />

3 Hello {{ Auth::user()->username }}<br />

4 Welcome to your sparse profile page.<br />

5 @stop<br />

.<br />

This file should be saved as app/views/user/profile.blade.php.<br />

1 Route::any("/profile", [<br />

2 "as" => "user/profile",<br />

3 "uses" => "UserController@profile"<br />

4 ]);<br />

.<br />

This was extracted from app/routes.php.<br />

1 public function profile()<br />

2 {<br />

3 return View::make("user/profile");<br />

4 }<br />

.<br />

This was extracted from app/controllers/UserController.php.<br />

Once the user is logged in, we can get access to their record by calling the Auth::user() method.<br />

This returns an instance of the User model (if we’re using the Eloquent auth driver, or a plain old<br />

PHP object if we’re using the Database driver).<br />

.<br />

You can find out more about the Auth class at http://laravel.com/docs/security#authenticatingusers.

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

Saved successfully!

Ooh no, something went wrong!