Conditions | 2 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function rules() |
||
29 | { |
||
30 | /** @var Comment $comment */ |
||
31 | $comment = $this->route('comment'); |
||
32 | $rule = Rule::requiredIf(!$comment->exists && !$this->input('parent_id')); |
||
33 | |||
34 | return [ |
||
35 | 'text' => 'required|string', |
||
36 | 'parent_id' => [ |
||
37 | 'nullable', |
||
38 | 'int', |
||
39 | Rule::exists('comments', 'id')->whereNull('parent_id') |
||
40 | ], |
||
41 | 'resource_id' => [ |
||
42 | 'bail', |
||
43 | $rule, |
||
44 | 'nullable', |
||
45 | 'int' |
||
46 | ], |
||
47 | 'resource_type' => [ |
||
48 | 'bail', |
||
49 | $rule, |
||
50 | Rule::in([Guide::class, Job::class]) |
||
51 | ] |
||
55 |