Merge remote-tracking branch 'origin/master' into mhmfajar
This commit is contained in:
@@ -20,6 +20,10 @@ class File extends Model
|
||||
'path',
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'url'
|
||||
];
|
||||
|
||||
public static $file_directories = [
|
||||
'import-temp' => 'import-temp/',
|
||||
'avatar' => 'user-avatar/',
|
||||
@@ -41,6 +45,11 @@ class File extends Model
|
||||
return $type . '-' . $id . '-' . Str::random(10);
|
||||
}
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return url($this->path);
|
||||
}
|
||||
|
||||
public static function storeFile($type, $id, $file)
|
||||
{
|
||||
$fileName = self::getFileName($type, $id);
|
||||
|
||||
@@ -88,8 +88,18 @@ class Person extends Model
|
||||
return $this->morphOne(File::class, 'fileable')->where('type', 'avatar')->latestOfMany();
|
||||
}
|
||||
|
||||
public function families()
|
||||
{
|
||||
return $this->belongsToMany(Person::class, 'family_relations', 'owner_id', 'person_id')->withPivot(['relation_with_owner']);
|
||||
}
|
||||
|
||||
public function familyOwner()
|
||||
{
|
||||
return $this->hasOne(Family::class, 'person_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ class User extends Authenticatable
|
||||
'otp_created_at' => 'datetime'
|
||||
];
|
||||
|
||||
public $with = [
|
||||
'metas'
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'meta'
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user