61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Scopes\CommonModel;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
/**
|
|
* Ein Block einer Dokumentvorlage. Bewusst `CommonModel` (kein `SiteScope`): die Vorlage gilt app-weit,
|
|
* tenant-spezifisch sind nur die eingesetzten Werte.
|
|
*
|
|
* @property string $document_type
|
|
* @property string $block
|
|
* @property string|null $content
|
|
* @property int $sort_order
|
|
* @property bool $editable
|
|
*/
|
|
class DocumentTemplate extends CommonModel
|
|
{
|
|
public const string TYPE_PARTICIPANT_INVOICE = 'participant_invoice';
|
|
|
|
public const string TYPE_PARTICIPANT_REFUND = 'participant_refund';
|
|
|
|
/** Seitengerüst -- enthält die `{block:...}`-Platzhalter und bestimmt damit die Anordnung. */
|
|
public const string BLOCK_LAYOUT = 'layout';
|
|
|
|
/** CSS des Dokuments. */
|
|
public const string BLOCK_STYLE = 'style';
|
|
|
|
/** Der Inhaltsblock. Bei der Rechnung generiert und gesperrt, beim Erstattungsbeleg pflegbar. */
|
|
public const string BLOCK_BODY = 'body';
|
|
|
|
protected $table = 'document_templates';
|
|
|
|
protected $fillable = [
|
|
'document_type',
|
|
'block',
|
|
'content',
|
|
'sort_order',
|
|
'editable',
|
|
];
|
|
|
|
protected $casts = [
|
|
'sort_order' => 'integer',
|
|
'editable' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Alle Blöcke einer Dokumentart, nach Block-Slug adressierbar.
|
|
*
|
|
* @return Collection<string, self>
|
|
*/
|
|
public static function forType(string $documentType): Collection
|
|
{
|
|
return self::where('document_type', $documentType)
|
|
->orderBy('sort_order')
|
|
->get()
|
|
->keyBy('block');
|
|
}
|
|
}
|