ldc-supportweb/app/Http/Requests/Bo/Labels/StoreLabelRequest.php
2025-04-23 12:24:31 +02:00

49 lines
1 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Labels;
use App\Rules\Hex;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreLabelRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::allows('isAdmin');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'name' => 'required|string|min:2|max:255|unique:labels,name',
'color' => [
'required',
new Hex(),
],
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'name' => trans('validation.attributes.name'),
'color' => trans('validation.attributes.color'),
];
}
}