29 lines
599 B
PHP
29 lines
599 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasUuid;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Person extends Model
|
|
{
|
|
use HasUuid;
|
|
|
|
protected $table = 'persons';
|
|
|
|
protected $fillable = ['uuid', 'name', 'avatar_color', 'user_id', 'presence', 'presence_changed_at'];
|
|
|
|
protected $casts = ['presence_changed_at' => 'datetime'];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isHome(): bool
|
|
{
|
|
return $this->presence === 'home';
|
|
}
|
|
}
|