diff --git a/app/Models/DeviceModel.php b/app/Models/DeviceModel.php index ded5c39..18750ea 100644 --- a/app/Models/DeviceModel.php +++ b/app/Models/DeviceModel.php @@ -31,6 +31,35 @@ final class DeviceModel extends Model return null; } + //if higher then 4 return 4bit + if ($this->bit_depth > 4) { + return '4bit'; + } + return $this->bit_depth.'bit'; } + +/** + * Returns the scale level based on the device width. + */ + public function getScaleLevelAttribute(): ?string + { + if (! $this->width) { + return null; + } + + if ($this->width > 800 && $this->width <= 1000) { + return 'large'; + } + + if ($this->width > 1000 && $this->width <= 1400) { + return 'xlarge'; + } + + if ($this->width > 1400) { + return 'xxlarge'; + } + + return null; + } } diff --git a/app/Models/Plugin.php b/app/Models/Plugin.php index 948e323..382751d 100644 --- a/app/Models/Plugin.php +++ b/app/Models/Plugin.php @@ -346,6 +346,7 @@ class Plugin extends Model return view('trmnl-layouts.single', [ 'colorDepth' => $device?->deviceModel?->color_depth, 'deviceVariant' => $device?->deviceModel?->name ?? 'og', + 'scaleLevel' => $device?->deviceModel?->scale_level, 'slot' => $renderedContent, ])->render(); } @@ -358,6 +359,7 @@ class Plugin extends Model return view('trmnl-layouts.single', [ 'colorDepth' => $device?->deviceModel?->color_depth, 'deviceVariant' => $device?->deviceModel?->name ?? 'og', + 'scaleLevel' => $device?->deviceModel?->scale_level, 'slot' => view($this->render_markup_view, [ 'size' => $size, 'data' => $this->data_payload,