Passed
Push — main ( 03ed8c...5e2119 )
by PRATIK
05:01 queued 11s
created

BlockRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 16
c 2
b 1
f 1
dl 0
loc 44
rs 10
wmc 3
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
            'type' => strtolower(trim($this->type))
29
        ]);
30
    }
31
32
    /**
33
     * Get the validation rules that apply to the request.
34
     *
35
     * @return array
36
     */
37
    public function rules()
38
    {
39
        $id = $this->block->id ?? '';
40
41
        return [
42
<<<<<<< HEAD
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_SL, expecting ',' or ']' on line 42 at column 0
Loading history...
43
            'code' => 'required|max:255|unique:blocks,code,' . $id,
44
            'type' => 'required|max:255',
45
            'name' => 'required|max:255|unique:blocks,name,' . $id,
46
=======
47
            'code' => 'required|max:255|unique:blocks,code,'.$id,
48
            'name' => 'required|max:255|unique:blocks,name,'.$id,
49
>>>>>>> 03ed8c22796652ffecb9c7cedb0423656ccc6e3b
50
            'image' => 'nullable|file|image|max:3000',
51
            'version' => 'required|numeric|max:60',
52
            'theme' => 'nullable|numeric|max:60',
53
            'page' => 'nullable|max:255',
54
            'location' => 'required|max:255',
55
            'position' => 'sometimes|numeric',
56
            'body' => 'nullable|max:55000',
57
            'setting' => 'nullable',
58
            'active' => 'sometimes|boolean',
59
        ];
60
    }
61
}
62