TeamRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 38
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A prepareForValidation() 0 4 2
A rules() 0 13 1
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