37 lines
877 B
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Providers;
2020-10-14 17:07:59 +03:00
use Illuminate\Contracts\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Access\Gate;
2019-11-16 10:21:14 +03:00
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as Provider;
2017-09-14 22:21:00 +03:00
2019-11-16 10:21:14 +03:00
class Auth extends Provider
2017-09-14 22:21:00 +03:00
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
2020-10-14 17:07:59 +03:00
//'App\Models\Model' => 'App\Policies\ModelPolicy',
2017-09-14 22:21:00 +03:00
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
2020-10-14 17:07:59 +03:00
// Register permissions to Laravel Gate
app(Gate::class)->before(function (Authorizable $user, string $ability) {
if (method_exists($user, 'hasPermission')) {
return $user->hasPermission($ability) ?: null;
}
});
2017-09-14 22:21:00 +03:00
}
}