blue-twilight/app/Http/Controllers/Controller.php

28 lines
702 B
PHP

<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
/**
* Gets either the authenticated user, or a user object representing the anonymous user.
* @return User
*/
protected function getUser()
{
$user = Auth::user();
return (is_null($user)
? User::anonymous()
: $user);
}
}