33 lines
746 B
PHP
33 lines
746 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasUuid;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Audit of every command sent to a device — who/what switched which entity when (H1).
|
|
* Indispensable for debugging "why did the light turn on?".
|
|
*/
|
|
class Command extends Model
|
|
{
|
|
use HasUuid;
|
|
|
|
protected $fillable = [
|
|
'uuid', 'device_id', 'entity_id', 'source', 'user_id', 'command', 'payload', 'result',
|
|
];
|
|
|
|
protected $casts = ['payload' => 'array'];
|
|
|
|
public function device(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Device::class);
|
|
}
|
|
|
|
public function entity(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Entity::class);
|
|
}
|
|
}
|