42 lines
792 B
PHP
42 lines
792 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use PDF;
|
|
|
|
class GeneratedDocument extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public $fillable = [
|
|
'type',
|
|
'title',
|
|
'document_type',
|
|
'html_content',
|
|
'system_origin',
|
|
'parent_id'
|
|
];
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(GeneratedDocument::class, 'parent_id');
|
|
}
|
|
|
|
public function childs()
|
|
{
|
|
return $this->hasMany(GeneratedDocument::class, 'parent_id');
|
|
}
|
|
|
|
public function generated_documentable()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function makePdf()
|
|
{
|
|
return PDF::loadFile(route('generated-document.show', $this->id));
|
|
}
|
|
}
|