Files
SkinbaseNova/app/Http/Requests/Groups/StoreGroupChallengeRequest.php

44 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Groups;
use Illuminate\Foundation\Http\FormRequest;
class StoreGroupChallengeRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'title' => ['required', 'string', 'min:2', 'max:180'],
'summary' => ['nullable', 'string', 'max:320'],
'description' => ['nullable', 'string', 'max:40000'],
'cover_path' => ['nullable', 'string', 'max:2048'],
'cover_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:5120'],
'visibility' => ['nullable', 'in:' . implode(',', (array) config('groups.challenges.visibility_options', []))],
'participation_scope' => ['nullable', 'in:' . implode(',', (array) config('groups.challenges.participation_scopes', []))],
'status' => ['nullable', 'in:' . implode(',', (array) config('groups.challenges.statuses', []))],
'start_at' => ['nullable', 'date'],
'end_at' => ['nullable', 'date', 'after_or_equal:start_at'],
'rules_text' => ['nullable', 'string', 'max:20000'],
'submission_instructions' => ['nullable', 'string', 'max:20000'],
'judging_mode' => ['nullable', 'in:' . implode(',', (array) config('groups.challenges.judging_modes', []))],
'linked_collection_id' => ['nullable', 'integer'],
'linked_project_id' => ['nullable', 'integer'],
'featured_artwork_id' => ['nullable', 'integer'],
'outcomes' => ['nullable', 'array'],
'outcomes.*.artwork_id' => ['required_with:outcomes', 'integer'],
'outcomes.*.outcome_type' => ['required_with:outcomes', 'in:' . implode(',', (array) config('groups.challenges.outcome_types', []))],
'outcomes.*.position' => ['nullable', 'integer', 'min:1'],
'outcomes.*.sort_order' => ['nullable', 'integer', 'min:0'],
'outcomes.*.title_override' => ['nullable', 'string', 'max:120'],
'outcomes.*.note' => ['nullable', 'string', 'max:2000'],
];
}
}