adds validation rules for label names
This commit is contained in:
parent
dd08642a7c
commit
69d255f584
1 changed files with 11 additions and 1 deletions
|
@ -2,8 +2,11 @@
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Labels\Label;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class StoreLabelSettings extends FormRequest
|
class StoreLabelSettings extends FormRequest
|
||||||
{
|
{
|
||||||
|
@ -22,6 +25,10 @@ class StoreLabelSettings extends FormRequest
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
$names = Label::find()?->map(function ($label) {
|
||||||
|
return $label->getName();
|
||||||
|
})->values()->toArray();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'labels_per_page' => 'numeric',
|
'labels_per_page' => 'numeric',
|
||||||
'labels_width' => 'numeric',
|
'labels_width' => 'numeric',
|
||||||
|
@ -36,7 +43,10 @@ class StoreLabelSettings extends FormRequest
|
||||||
'labels_pagewidth' => 'numeric|nullable',
|
'labels_pagewidth' => 'numeric|nullable',
|
||||||
'labels_pageheight' => 'numeric|nullable',
|
'labels_pageheight' => 'numeric|nullable',
|
||||||
'qr_text' => 'max:31|nullable',
|
'qr_text' => 'max:31|nullable',
|
||||||
'label2_template' => 'required|string',
|
'label2_template' => [
|
||||||
|
'required',
|
||||||
|
Rule::in($names),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue