-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathstore-request.blade.php
109 lines (95 loc) · 3.07 KB
/
store-request.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
@php echo "<?php"
@endphp
namespace App\Http\Requests\Admin\{{ $modelWithNamespaceFromDefault }};
@php
if($translatable->count() > 0) {
$translatableColumns = $columns->filter(function($column) use ($translatable) {
return in_array($column['name'], $translatable->toArray());
});
$standardColumn = $columns->reject(function($column) use ($translatable) {
return in_array($column['name'], $translatable->toArray());
});
}
@endphp
@if($translatable->count() > 0)use Brackets\Translatable\TranslatableFormRequest;
@else
use Illuminate\Foundation\Http\FormRequest;
@endif
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
@if($translatable->count() > 0)class Store{{ $modelBaseName }} extends TranslatableFormRequest
@else
class Store{{ $modelBaseName }} extends FormRequest
@endif
{
/**
* Determine if the user is authorized to make this request.
*
* {{'@'}}return bool
*/
public function authorize(): bool
{
return Gate::allows('admin.{{ $modelDotNotation }}.create');
}
@if($translatable->count() > 0)/**
* Get the validation rules that apply to the requests untranslatable fields.
*
* {{'@'}}return array
*/
public function untranslatableRules(): array {
return [
@foreach($standardColumn as $column)'{{ $column['name'] }}' => [{!! implode(', ', (array) $column['serverStoreRules']) !!}],
@endforeach
@if (count($relations))
@if (count($relations['belongsToMany']))
@foreach($relations['belongsToMany'] as $belongsToMany)'{{ $belongsToMany['related_table'] }}' => [{!! implode(', ', ['\'array\'']) !!}],
@endforeach
@endif
@endif
];
}
/**
* Get the validation rules that apply to the requests translatable fields.
*
* {{'@'}}return array
*/
public function translatableRules($locale): array {
return [
@foreach($translatableColumns as $column)'{{ $column['name'] }}' => [{!! implode(', ', (array) $column['serverStoreRules']) !!}],
@endforeach
];
}
@else
/**
* Get the validation rules that apply to the request.
*
* {{'@'}}return array
*/
public function rules(): array
{
return [
@foreach($columns as $column)
@if(!($column['name'] == "updated_by_admin_user_id" || $column['name'] == "created_by_admin_user_id" ))'{{ $column['name'] }}' => [{!! implode(', ', (array) $column['serverStoreRules']) !!}],
@endif
@endforeach
@if (count($relations))
@if (count($relations['belongsToMany']))
@foreach($relations['belongsToMany'] as $belongsToMany)'{{ $belongsToMany['related_table'] }}' => [{!! implode(', ', ['\'array\'']) !!}],
@endforeach
@endif
@endif
];
}
@endif
/**
* Modify input data
*
* {{'@'}}return array
*/
public function getSanitized(): array
{
$sanitized = $this->validated();
//Add your code for manipulation with request data here
return $sanitized;
}
}