|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Http\Requests; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
|
6
|
|
|
use Illuminate\Support\Str; |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class PopupRequest extends FormRequest |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Determine if the user is authorized to make this request. |
|
13
|
|
|
*/ |
|
14
|
|
|
public function authorize(): bool |
|
15
|
|
|
{ |
|
16
|
|
|
return true; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
protected function prepareForValidation(): void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->merge([ |
|
22
|
|
|
'slug' => ! is_null($this->name) ? Str::slug($this->name) : null, |
|
23
|
|
|
'meta_name' => $this->popup->meta_name ?? $this->meta_name ?? $this->name ?? null, |
|
24
|
|
|
'meta_description' => $this->popup->meta_description ?? $this->meta_description ?? $this->excerpt ?? null, |
|
25
|
|
|
]); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Get the validation rules that apply to the request. |
|
30
|
|
|
* |
|
31
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string> |
|
32
|
|
|
*/ |
|
33
|
|
|
public function rules(): array |
|
34
|
|
|
{ |
|
35
|
|
|
$id = $this->popup->id ?? ''; |
|
36
|
|
|
return [ |
|
37
|
|
|
'slug' => 'required|max:100|unique:'.config('website.table_prefix', 'website').'_categories,slug,'.$id, |
|
38
|
|
|
'name' => 'required|max:100|unique:'.config('website.table_prefix', 'website').'_categories,name,'.$id, |
|
39
|
|
|
'excerpt' => 'nullable|max:5500', |
|
40
|
|
|
'description' => 'nullable|max:55000', |
|
41
|
|
|
'category_id' => 'nullable|exists:'.config('website.table_prefix', 'website').'_categories,id', |
|
42
|
|
|
'active' => 'sometimes|boolean', |
|
43
|
|
|
'position' => 'nullable|numeric', |
|
44
|
|
|
'icon' => 'nullable|max:255', |
|
45
|
|
|
'color' => 'nullable|max:255', |
|
46
|
|
|
'expire' => 'nullable|max:255', |
|
47
|
|
|
'data' => 'nullable', |
|
48
|
|
|
'meta_name' => 'nullable|max:100', |
|
49
|
|
|
'meta_description' => 'nullable|max:255', |
|
50
|
|
|
'meta_keywords' => 'nullable|max:100', |
|
51
|
|
|
'videos' => 'nullable', |
|
52
|
|
|
'popup' => 'sometimes|numeric', |
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|