|
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
|
|
|
'code' => 'required|max:255|unique:blocks,code,' . $id, |
|
43
|
|
|
'type' => 'required|max:255', |
|
44
|
|
|
'name' => 'required|max:255|unique:blocks,name,' . $id, |
|
45
|
|
|
'image' => 'nullable|file|image|max:3000', |
|
46
|
|
|
'version' => 'required|numeric|max:60', |
|
47
|
|
|
'theme' => 'nullable|numeric|max:60', |
|
48
|
|
|
'page' => 'nullable|max:255', |
|
49
|
|
|
'location' => 'required|max:255', |
|
50
|
|
|
'position' => 'sometimes|numeric', |
|
51
|
|
|
'body' => 'nullable|max:55000', |
|
52
|
|
|
'setting' => 'nullable', |
|
53
|
|
|
'active' => 'sometimes|boolean', |
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|