HovedprosjektWebApp/app/Providers/AuthServiceProvider.php

40 lines
796 B
PHP
Raw Normal View History

2020-03-03 10:48:38 +01:00
<?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;
2020-03-03 10:48:38 +01:00
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
BlogPost::class => BlogPostPolicy::class,
2020-03-03 10:48:38 +01:00
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
}
2020-03-03 10:48:38 +01:00
public function register()
{
SessionGuard::macro('admin', function () {
return \Auth::user()->admin;
});
2020-03-03 10:48:38 +01:00
}
}