1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-01-31 12:11:37 +01:00

Added some user/view helper methods

This commit is contained in:
Dan Brown 2015-08-24 21:10:04 +01:00
parent b68f2803fc
commit 0513239c25
2 changed files with 27 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -33,6 +33,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.