From 3906747b1a3d72a121988a130df0d04bd285e4d2 Mon Sep 17 00:00:00 2001 From: Benjamin Nussbaum Date: Sun, 16 Mar 2025 21:45:39 +0100 Subject: [PATCH] feat: proxy firmware update & url through to device --- app/Models/Device.php | 17 +++++++++++++++++ routes/api.php | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Models/Device.php b/app/Models/Device.php index a57c0ee..99f5338 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -15,6 +15,7 @@ class Device extends Model protected $casts = [ 'proxy_cloud' => 'boolean', 'last_log_request' => 'json', + 'proxy_cloud_response' => 'json', ]; public function getBatteryPercentAttribute() @@ -52,6 +53,22 @@ class Device extends Model } } + public function getUpdateFirmwareAttribute() : bool + { + if ($this->proxy_cloud_response && $this->proxy_cloud_response['update_firmware']) { + return true; + } + return false; + } + + public function getFirmwareUrlAttribute() : string | null + { + if ($this->proxy_cloud_response && $this->proxy_cloud_response['firmware_url']) { + return $this->proxy_cloud_response['firmware_url']; + } + return null; + } + public function playlists(): HasMany { return $this->hasMany(Playlist::class); diff --git a/routes/api.php b/routes/api.php index eebac68..ee36d76 100644 --- a/routes/api.php +++ b/routes/api.php @@ -80,8 +80,8 @@ Route::get('/display', function (Request $request) { 'filename' => $filename, 'refresh_rate' => $device->default_refresh_interval, 'reset_firmware' => false, - 'update_firmware' => false, - 'firmware_url' => null, + 'update_firmware' => $device->update_firmware, + 'firmware_url' => $device->firmware_url, 'special_function' => 'sleep', ]); });