Completed
Push — develop ( fd6fdd...e2e6ec )
by Abdelrahman
01:24
created

ContactFormRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Contacts\Http\Requests\Tenantarea;
6
7
use Rinvex\Support\Http\Requests\FormRequest;
8
9
class ContactFormRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize()
17
    {
18
        return true;
19
    }
20
21
    /**
22
     * Process given request data before validation.
23
     *
24
     * @param array $data
25
     *
26
     * @return array
27
     */
28
    public function process($data)
29
    {
30
        $data['entity_id'] = $this->user()->id;
31
        $data['entity_type'] = get_class($this->user());
32
33
        return $data;
34
    }
35
36
    /**
37
     * Get the validation rules that apply to the request.
38
     *
39
     * @return array
40
     */
41
    public function rules()
42
    {
43
        $contact = $this->route('contact') ?? app('rinvex.contacts.contact');
44
        $contact->updateRulesUniques();
45
46
        return $contact->getRules();
47
    }
48
}
49