[WIP] A
This commit is contained in:
41
app/Models/GeneratedDocument.php
Normal file
41
app/Models/GeneratedDocument.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user