MangaDex/app/Providers/AuthServiceProvider.php

42 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2023-08-22 15:54:26 +06:30
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
2023-09-06 14:37:03 +06:30
use App\Models\User;
use App\Models\Manga;
2023-09-20 21:19:28 +06:30
use App\Models\Reply;
2023-09-06 14:37:03 +06:30
use App\Models\Chapter;
use App\Policies\MangaPolicy;
2023-09-20 21:19:28 +06:30
use App\Policies\ReplyPolicy;
2023-09-06 14:37:03 +06:30
use App\Policies\ChapterPolicy;
2023-09-20 21:19:28 +06:30
use App\Policies\CommentPolicy;
2023-09-06 14:37:03 +06:30
use Illuminate\Support\Facades\Gate;
2023-08-22 15:54:26 +06:30
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
2023-09-06 14:37:03 +06:30
Manga::class => MangaPolicy::class,
2023-09-20 21:19:28 +06:30
Chapter::class => ChapterPolicy::class,
Comment::class => CommentPolicy::class,
Reply::class => ReplyPolicy::class
2023-08-22 15:54:26 +06:30
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
2023-09-06 14:37:03 +06:30
//gates here
Gate::define('admin-only', fn(User $user) => $user->role === 'admin');
2023-09-08 00:32:45 +06:30
Gate::define('dashboard', fn(User $user) => $user->role === 'admin' || $user->role === 'author');
2023-08-22 15:54:26 +06:30
}
}