This commit is contained in:
R
2022-09-17 00:51:02 +07:00
parent 300b53942d
commit a9f29cd19d
28 changed files with 1122 additions and 13 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Practitioner extends Model
{
use HasFactory;
protected $fillable = [
'person_id'
];
public $appends = [
'meta'
];
public function getMetaAttribute()
{
$orgMeta = [];
foreach ($this->metas as $meta) {
$orgMeta[$meta->type] = $meta->value;
}
return (object) $orgMeta;
}
public function person()
{
return $this->belongsTo(Person::class, 'person_id');
}
public function metas()
{
return $this->morphMany(Meta::class, 'metaable');
}
}