34 lines
700 B
PHP
34 lines
700 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', 'mac', 'presence', 'presence_changed_at', 'last_seen_home_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'presence_changed_at' => 'datetime',
|
|
'last_seen_home_at' => 'datetime',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isHome(): bool
|
|
{
|
|
return $this->presence === 'home';
|
|
}
|
|
}
|