Add Update Profile

This commit is contained in:
R
2022-09-20 09:31:26 +07:00
parent fc263e867a
commit 07bfbaefe0
7 changed files with 258 additions and 6 deletions

View File

@@ -18,12 +18,13 @@ class User extends Authenticatable
* @var array<int, string>
*/
protected $fillable = [
'person_id',
'name',
'email',
'password',
'phone',
'otp',
'otp_created_at'
'otp_created_at',
];
/**
@@ -46,8 +47,32 @@ class User extends Authenticatable
'otp_created_at' => 'datetime'
];
public $appends = [
'meta'
];
public function getMetaAttribute()
{
$orgMeta = [];
foreach ($this->metas as $meta) {
$orgMeta[$meta->type] = $meta->value;
}
return (object) $orgMeta;
}
public function managedCorporates()
{
return $this->belongsToMany(Corporate::class, 'corporate_manager', 'user_id', 'corporate_id');
}
public function metas()
{
return $this->morphMany(Meta::class, 'metaable');
}
public function person()
{
return $this->belongsTo(Person::class, 'person_id');
}
}