Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthServiceProvider
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 boot
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Providers;
4
5use App\Models\Vote;
6use App\Policies\VotePolicy;
7use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
8use Illuminate\Support\Facades\Gate;
9
10class AuthServiceProvider extends ServiceProvider
11{
12    /**
13     * The model to policy mappings for the application.
14     *
15     * @var array<class-string, class-string>
16     */
17    protected $policies = [
18        Vote::class => VotePolicy::class,
19    ];
20
21    /**
22     * Register any authentication / authorization services.
23     */
24    public function boot(): void
25    {
26        $this->registerPolicies();
27
28        // Register custom gates
29        Gate::define('voteOnJoke', [VotePolicy::class, 'voteOnJoke']);
30        Gate::define('removeVoteFromJoke', [VotePolicy::class, 'removeVoteFromJoke']);
31        Gate::define('clearUserVotes', [VotePolicy::class, 'clearUserVotes']);
32        Gate::define('clearAllVotes', [VotePolicy::class, 'clearAllVotes']);
33    }
34}