jonnybarnes.uk/app/Http/Requests/MicropubRequest.php
Jonny Barnes 1137d2a07e
Move request parsing into DTOs via fromRequest(), expand update handler
Each DTO now owns its own parsing logic via fromRequest(), removing
the normalization layer from MicropubRequest entirely. UpdateHandler
gains delete support and allows replace/add/delete to compose in a
single request rather than being mutually exclusive.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 20:39:50 +00:00

39 lines
832 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MicropubRequest extends FormRequest
{
public function rules(): array
{
return [
// Validation rules
];
}
public function getType(): ?string
{
if ($this->isJson()) {
$data = $this->json()->all();
if (isset($data['action']) && $data['action'] === 'update') {
return 'update';
}
if (isset($data['type']) && is_array($data['type'])) {
$type = current($data['type']);
if (str_starts_with($type, 'h-')) {
return substr($type, 2);
}
}
return null;
}
return $this->input('h') ?: null;
}
}