1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Http\Requests; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
6
|
|
|
use Illuminate\Support\Str; |
7
|
|
|
|
8
|
|
|
class TeamRequest 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->name) ? Str::slug($this->name) : 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->team->id ?? ''; |
36
|
|
|
|
37
|
|
|
return [ |
38
|
|
|
'name' => 'required|max:100|unique:'.config('website.table_prefix', 'website').'_teams,name,'.$id, |
39
|
|
|
'slug' => 'required|max:100|unique:'.config('website.table_prefix', 'website').'_teams,slug,'.$id, |
40
|
|
|
'short_message' => 'nullable|max:255', |
41
|
|
|
'description' => 'nullable|max:55000', |
42
|
|
|
'social_medias' => 'nullable', |
43
|
|
|
'phone' => 'nullable|max:100', |
44
|
|
|
'group' => 'nullable|numeric', |
45
|
|
|
'position' => 'nullable|numeric', |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|