Passed
Push — main ( 0c0937...7a01df )
by PRATIK
03:45
created

BlockRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 10
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 12
rs 9.9332
1
<?php
2
3
namespace Adminetic\Website\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
class BlockRequest extends FormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14
    public function authorize()
15
    {
16
        return true;
17
    }
18
19
    /**
20
     * Prepare the data for validation.
21
     *
22
     * @return void
23
     */
24
    protected function prepareForValidation()
25
    {
26
        $this->merge([
27
            'code' => $this->block->code ?? rand(100000, 999999)
28
        ]);
29
    }
30
31
    /**
32
     * Get the validation rules that apply to the request.
33
     *
34
     * @return array
35
     */
36
    public function rules()
37
    {
38
        $id = $this->block->id ?? '';
39
        return [
40
            'code' => 'required|max:255|unique:blocks,code,' . $id,
41
            'name' => 'required|max:255|unique:blocks,name,' . $id,
42
            'image' => 'nullable|file|image|max:3000',
43
            'page' => 'nullable|max:255',
44
            'location' => 'required|max:255',
45
            'position' => 'sometimes|numeric',
46
            'body' => 'nullable|max:55000',
47
            'active' => 'sometimes|boolean'
48
        ];
49
    }
50
}
51