| Total Complexity | 5 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class PolyExistsRule implements Rule |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * The value in the the _type column, sepecifying the type of a polymorphic relationship. |
||
| 14 | * eg 'applicant' or 'application' |
||
| 15 | * |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $poly_type; |
||
| 19 | |||
| 20 | /** |
||
|
1 ignored issue
–
show
|
|||
| 21 | * Create a new rule instance. |
||
| 22 | * |
||
| 23 | * @return void |
||
| 24 | */ |
||
| 25 | public function __construct($poly_type) |
||
| 26 | { |
||
| 27 | $this->poly_type = $poly_type; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
|
2 ignored issues
–
show
|
|||
| 31 | * Determine if $value is a valid id of the model specified in the _type polymorphic relation column. |
||
| 32 | * An example of how to use this rule: |
||
| 33 | * 'commentable_id' => [new PolyTypeRule('user')] |
||
| 34 | * |
||
| 35 | */ |
||
|
1 ignored issue
–
show
|
|||
| 36 | public function passes($attribute, $value) |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get the validation error message. |
||
| 53 | * |
||
| 54 | * @return string |
||
| 55 | */ |
||
| 56 | public function message() |
||
| 61 |