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