RequestAdminNews.php
1.26 KB
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
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Arr;
class RequestAdminNews extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
if (in_array($this->route()->getName(), ['admin.new_admin_update'])) {
// получаем модель Pages через маршрут admin/editor-pages/edit/{page}
$model = $this->route('new_admin_edit');
} else {
$unique = 'unique:news,slug';
$Array1['slug'] = [
'required',
'max:255',
$unique,
'regex:~^[-_a-z0-9]+$~i',
];
}
$Array1 = [
'title' => [
'required',
'string',
'min:3',
'max:255',
],
'text' => [
'required',
'min:50',
'max:99999999'
],
];
return $Array1;
}
}