2023-11-23 19:27:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2023-11-24 00:16:43 +01:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2023-11-23 19:27:43 +01:00
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
|
2023-11-24 00:16:43 +01:00
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\Trace\Channel as TraceChannel;
|
|
|
|
|
2023-11-23 19:27:43 +01:00
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The model to policy mappings for the application.
|
|
|
|
*
|
|
|
|
* @var array<class-string, class-string>
|
|
|
|
*/
|
|
|
|
protected $policies = [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any authentication / authorization services.
|
|
|
|
*/
|
|
|
|
public function boot(): void
|
|
|
|
{
|
2023-11-24 00:16:43 +01:00
|
|
|
Gate::define('access-channel', function(User $user, TraceChannel $channel) {
|
|
|
|
return $user->hasChannelPermission($channel);
|
|
|
|
});
|
2023-11-23 19:27:43 +01:00
|
|
|
}
|
|
|
|
}
|