1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jeremykenedy\LaravelBlocker\App\Http\Requests; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
|
|
|
|
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use jeremykenedy\LaravelBlocker\App\Rules\UniqueBlockerItemValueEmail; |
8
|
|
|
|
9
|
|
|
class StoreBlockerRequest extends FormRequest |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Determine if the user is authorized to make this request. |
13
|
|
|
* |
14
|
|
|
* @return bool |
15
|
|
|
*/ |
16
|
|
|
public function authorize() |
17
|
|
|
{ |
18
|
|
|
if (config('laravelblocker.rolesEnabled')) { |
|
|
|
|
19
|
|
|
return config('laravelblocker.rolesMiddlware'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
return true; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Get the validation rules that apply to the request. |
27
|
|
|
* |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
public function rules() |
31
|
|
|
{ |
32
|
|
|
$id = $this->route('blocker'); |
33
|
|
|
|
34
|
|
|
return [ |
35
|
|
|
'typeId' => 'required|max:255|integer', |
36
|
|
|
'value' => ['required', 'max:255', 'string', 'unique:laravel_blocker,value,'.$id.',id', new UniqueBlockerItemValueEmail(Request::input('typeId'))], |
37
|
|
|
'note' => 'nullable|max:500|string', |
38
|
|
|
'userId' => 'nullable|max:255|integer', |
39
|
|
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get the error messages for the defined validation rules. |
44
|
|
|
* |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function messages() |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'typeId.required' => trans('laravelblocker::laravelblocker.validation.blockedTypeRequired'), |
|
|
|
|
51
|
|
|
'value.required' => trans('laravelblocker::laravelblocker.validation.blockedValueRequired'), |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Return the fields and values for a Blocked Item. |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
|
|
public function blockedFillData() |
61
|
|
|
{ |
62
|
|
|
$userId = null; |
63
|
|
|
if ($this->userId) { |
64
|
|
|
$userId = $this->userId; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return [ |
68
|
|
|
'typeId' => $this->typeId, |
69
|
|
|
'value' => $this->value, |
70
|
|
|
'note' => $this->note, |
71
|
|
|
'userId' => $userId, |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths