Passed
Pull Request — main (#22)
by Seth
02:50
created

DynamicSettingUpdateRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace SaasReady\Http\Requests\DynamicSetting;
4
5
use Illuminate\Database\Eloquent\Model;
6
use SaasReady\Http\Requests\BaseFormRequest;
7
8
class DynamicSettingUpdateRequest extends BaseFormRequest
9
{
10
    public function authorize(): bool
11
    {
12
        return true;
13
    }
14
15
    public function rules(): array
16
    {
17
        return [
18
            'source_type' => 'nullable|string',
19
            'source_id' => 'nullable|int',
20
            'settings' => 'required|array',
21
        ];
22
    }
23
24
    public function getRelatedModel(): ?Model
25
    {
26
        return $this->source
27
            ??= $this->input('source_type')::find($this->input('source_id'));
28
    }
29
}
30