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

49
app/Models/Person.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Person extends Model
{
use HasFactory;
protected $table = 'persons';
protected $fillable = [
'nik',
'name_prefix',
'name',
'name_suffix',
'gender',
'birth_date',
'is_deceased',
'deceased_at',
'marital_status',
];
public function getFullNameAttribute()
{
$arr = [];
if (!empty($this->name_prefix)) {
$arr[] = $this->name_prefix;
}
$arr[] = $this->name;
if (!empty($this->name_suffix)) {
$arr[] = $this->name_suffix;
}
return implode(' ', $arr);
}
public function addresses()
{
return $this->morphMany(Address::class, 'addressable');
}
public function metas()
{
return $this->morphMany(Meta::class, 'metaable');
}
}