Files
sam-manage/app/Models/DocumentTemplateLink.php

43 lines
981 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class DocumentTemplateLink extends Model
{
protected $table = 'document_template_links';
protected $fillable = [
'template_id',
'link_key',
'label',
'link_type',
'source_table',
'search_params',
'display_fields',
'is_required',
'sort_order',
];
protected $casts = [
'search_params' => 'array',
'display_fields' => 'array',
'is_required' => 'boolean',
'sort_order' => 'integer',
];
public function template(): BelongsTo
{
return $this->belongsTo(DocumentTemplate::class, 'template_id');
}
public function linkValues(): HasMany
{
return $this->hasMany(DocumentTemplateLinkValue::class, 'link_id')
->orderBy('sort_order');
}
}