mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: calculate scale level, limit to 4-bit
This commit is contained in:
parent
8791a5154e
commit
85e887f8a5
2 changed files with 31 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue