HovedprosjektWebApp/app/Providers/AuthServiceProvider.php
2020-03-09 14:03:08 +01:00

40 lines
796 B
PHP

<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use App\BlogPost;
use App\Policies\BlogPostPolicy;
use Illuminate\Auth\SessionGuard;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
BlogPost::class => BlogPostPolicy::class,
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
}
public function register()
{
SessionGuard::macro('admin', function () {
return \Auth::user()->admin;
});
}
}