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