Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-08-24 21:10:04 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
0513239c25dcddf696ad9171f167295fa93661e9
0513239c
1 parent
b68f2803
Added some user/view helper methods
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
app/Http/Controllers/Controller.php
app/User.php
app/Http/Controllers/Controller.php
View file @
0513239
...
...
@@ -5,8 +5,24 @@ namespace Oxbow\Http\Controllers;
use
Illuminate\Foundation\Bus\DispatchesJobs
;
use
Illuminate\Routing\Controller
as
BaseController
;
use
Illuminate\Foundation\Validation\ValidatesRequests
;
use
Illuminate\Support\Facades\Auth
;
use
Oxbow\User
;
abstract
class
Controller
extends
BaseController
{
use
DispatchesJobs
,
ValidatesRequests
;
/**
* Controller constructor.
*/
public
function
__construct
()
{
view
()
->
share
(
'signedIn'
,
Auth
::
check
());
$user
=
Auth
::
user
();
if
(
!
$user
)
{
$user
=
User
::
getDefault
();
}
view
()
->
share
(
'user'
,
$user
);
}
}
...
...
app/User.php
View file @
0513239
...
...
@@ -34,6 +34,17 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
protected
$hidden
=
[
'password'
,
'remember_token'
];
/**
* Returns a default guest user.
*/
public
static
function
getDefault
()
{
return
new
static
([
'email'
=>
'guest'
,
'name'
=>
'Guest'
]);
}
/**
* Returns the user's avatar,
* Uses Gravatar as the avatar service.
* @param int $size
...
...
Please
register
or
sign in
to post a comment