hasComposition()

* renderRegion()
* draft and published-state handling
* document and placement scheduling
* disabled-placement filtering
* ordered region rendering
* safe fallback when composition tables or document views are missing
* compatibility with common alternative column names
This commit is contained in:
Mark Gregory
2026-07-27 09:43:42 +01:00
parent a211b10e29
commit c972808d0a
22 changed files with 455 additions and 754 deletions
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Modules\Content\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Content\Models\ContentDocument;
final class SaveContentDocumentRequest extends FormRequest
{
public function authorize(): bool { return true; }
public function rules(): array
{
$document = $this->route('document');
return [
'content_type_id' => ['required','integer','exists:content_types,id'],
'title' => ['required','string','max:255'],
'slug' => ['nullable','string','max:255', Rule::unique('content_documents','slug')->ignore($document instanceof ContentDocument ? $document->id : null)],
'status' => ['required', Rule::in(['draft','published','archived'])],
'data_json' => ['required','json'],
'published_at' => ['nullable','date'],
'expires_at' => ['nullable','date','after:published_at'],
];
}
public function payload(): array
{
$validated = $this->validated();
$validated['slug'] = filled($validated['slug'] ?? null) ? $validated['slug'] : str($validated['title'])->slug();
$validated['data'] = json_decode($validated['data_json'], true, flags: JSON_THROW_ON_ERROR);
unset($validated['data_json']);
return $validated;
}
}