Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
QuestionPolicy
n/a
0 / 0
n/a
0 / 0
2
n/a
0 / 0
 setPolicies
n/a
0 / 0
1
n/a
0 / 0
 questionBelongsToService
n/a
0 / 0
1
n/a
0 / 0
1<?php
2
3namespace App\Policies;
4
5use App\Models\Question;
6use App\Models\Service;
7use App\Policies\Rules\UserStaticRules as USR;
8use Kwaadpepper\CrudPolicies\Policies\RootPolicy;
9
10/**
11 * @codeCoverageIgnore
12 */
13class QuestionPolicy extends RootPolicy
14{
15    /**
16     * Init policies on call
17     *
18     * @return void
19     */
20    public function setPolicies()
21    {
22        /**
23         * This first rule to return true in a policy action authorises the action
24         */
25        $this->policies = [
26            'question' => [
27                'viewAny' => USR::make('everyOne'),
28                'view' => USR::make('everyOne'),
29                'update' => USR::make('everyOne'),
30                'create' => USR::make('everyOne'),
31                'delete' => USR::make('everyOne')
32            ]
33        ];
34    }
35
36    /**
37     * Check if the question belongs to the service
38     *
39     * @param Service  $service
40     * @param Question $question
41     * @return boolean
42     */
43    public function questionBelongsToService(Service $service, Question $question)
44    {
45        return $service->brand->id === $question->brand_id;
46    }
47}