optimizations
This commit is contained in:
34
app/Http/Requests/NovaCards/StoreNovaCardDraftRequest.php
Normal file
34
app/Http/Requests/NovaCards/StoreNovaCardDraftRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\NovaCards;
|
||||
|
||||
use App\Models\NovaCard;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreNovaCardDraftRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['nullable', 'string', 'min:2', 'max:' . (int) config('nova_cards.validation.title_max', 120)],
|
||||
'quote_text' => ['nullable', 'string', 'min:' . (int) config('nova_cards.validation.quote_min', 3), 'max:' . (int) config('nova_cards.validation.quote_max', 420)],
|
||||
'quote_author' => ['nullable', 'string', 'max:160'],
|
||||
'quote_source' => ['nullable', 'string', 'max:180'],
|
||||
'description' => ['nullable', 'string', 'max:' . (int) config('nova_cards.validation.description_max', 500)],
|
||||
'format' => ['nullable', Rule::in(array_keys((array) config('nova_cards.formats', [])))],
|
||||
'template_id' => ['nullable', 'integer', 'exists:nova_card_templates,id'],
|
||||
'category_id' => ['nullable', 'integer', 'exists:nova_card_categories,id'],
|
||||
'background_type' => ['nullable', Rule::in(['gradient', 'upload', 'template', 'solid'])],
|
||||
'tags' => ['nullable', 'array', 'max:' . (int) config('nova_cards.validation.max_tags', 8)],
|
||||
'tags.*' => ['string', 'min:2', 'max:32'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user