trypost/app/Http/Requests/App/Post/UpdatePostRequest.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2026-01-15 01:13:44 +00:00
<?php
declare(strict_types=1);
namespace App\Http\Requests\App\Post;
2026-01-15 01:13:44 +00:00
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
2026-01-15 01:13:44 +00:00
class UpdatePostRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
2026-01-15 17:24:39 +00:00
'status' => ['sometimes', 'string'],
'scheduled_at' => ['sometimes', 'nullable', 'string'],
2026-01-15 01:13:44 +00:00
'platforms' => ['sometimes', 'array'],
'platforms.*.id' => ['required', 'uuid', Rule::exists('post_platforms', 'id')->where('post_id', $this->route('post')->id ?? $this->route('post'))],
2026-01-15 01:13:44 +00:00
'platforms.*.content' => ['nullable', 'string', 'max:5000'],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $this->user()->currentWorkspace->id)],
2026-01-15 01:13:44 +00:00
];
}
public function messages(): array
{
return [
2026-01-15 17:24:39 +00:00
'scheduled_at.after' => 'The scheduled date must be in the future.',
2026-01-15 01:13:44 +00:00
];
}
}