'array', 'parameters' => 'array', 'sent_at' => 'datetime', 'delivered_at' => 'datetime', 'executed_at' => 'datetime', 'expires_at' => 'datetime', ]; /** * Get the device this command was sent to */ public function device(): BelongsTo { return $this->belongsTo(Device::class); } /** * Get the user who sent this command */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Scope for pending commands */ public function scopePending($query) { return $query->where('status', 'pending'); } /** * Scope for successful commands */ public function scopeSuccessful($query) { return $query->where('status', 'success'); } /** * Get status color */ public function getStatusColor(): string { return match ($this->status) { 'success' => 'green', 'failed' => 'red', 'pending' => 'yellow', default => 'gray' }; } }