2026-03-05 10:35:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Stickies;
|
|
|
|
|
|
|
|
|
|
use App\Enums\StaticPageType;
|
2026-05-28 11:54:19 +02:00
|
|
|
use App\Enums\StickiesColorEnum;
|
2026-03-05 10:35:06 +01:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
use Illuminate\Validation\Rules\Enum;
|
|
|
|
|
|
|
|
|
|
class StoreStickyRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('backend')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
2026-04-24 15:04:18 +02:00
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
2026-03-05 10:35:06 +01:00
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'type' => [
|
|
|
|
|
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
|
|
|
|
new Enum(StaticPageType::class)
|
|
|
|
|
],
|
|
|
|
|
'title' => 'required|string|between:3,255',
|
|
|
|
|
'anchor' => [
|
|
|
|
|
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
|
|
|
|
'string',
|
|
|
|
|
'between:3,255'
|
|
|
|
|
],
|
2026-05-28 11:54:19 +02:00
|
|
|
'color' => [
|
|
|
|
|
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
|
|
|
|
new Enum(StickiesColorEnum::class)
|
|
|
|
|
],
|
2026-03-05 10:35:06 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
2026-04-24 15:04:18 +02:00
|
|
|
* @return array<string, string>
|
2026-03-05 10:35:06 +01:00
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'type' => trans('validation.custom.type'),
|
|
|
|
|
'title' => trans('validation.attributes.title'),
|
|
|
|
|
'anchor' => trans('validation.custom.anchor'),
|
2026-08-06 09:57:35 +02:00
|
|
|
'color' => trans('validation.custom.color'),
|
2026-03-05 10:35:06 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|