Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
11 | class ApplicantHasRelationRule implements Rule |
||
12 | { |
||
13 | |||
14 | protected $applicant; |
||
15 | protected $relation; |
||
16 | |||
17 | /** |
||
18 | * Create a new rule instance. |
||
19 | * |
||
20 | * @param App\Models\Applicant $applicant |
||
21 | * @param string $relation |
||
22 | * @return void |
||
23 | */ |
||
24 | public function __construct($applicant, $relation) |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * This check passes if the model's relation contains an object whose id=$value |
||
32 | * @param [type] $attribute [description] |
||
33 | * @param [type] $value [description] |
||
34 | * @return [type] [description] |
||
35 | */ |
||
36 | public function passes($attribute, $value) |
||
37 | { |
||
38 | return $this->applicant->getRelationValue($this->relation) |
||
39 | ->pluck('id')->contains($value); |
||
40 | } |
||
41 | |||
42 | public function message() |
||
45 | } |
||
46 | } |
||
47 |