mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
chore: pint
This commit is contained in:
parent
25f36eaf54
commit
4c66761baa
12 changed files with 142 additions and 121 deletions
|
|
@ -182,10 +182,12 @@ class Device extends Model
|
|||
{
|
||||
return $this->belongsTo(Firmware::class, 'update_firmware_id');
|
||||
}
|
||||
|
||||
public function deviceModel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DeviceModel::class);
|
||||
}
|
||||
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(DeviceLog::class);
|
||||
|
|
@ -224,19 +226,20 @@ class Device extends Model
|
|||
if ($from < $to) {
|
||||
// Normal range, same day
|
||||
return $now->between($from, $to) ? (int) $now->diffInSeconds($to, false) : null;
|
||||
} else {
|
||||
// Overnight range
|
||||
if ($now->gte($from)) {
|
||||
// After 'from', before midnight
|
||||
return (int) $now->diffInSeconds($to->copy()->addDay(), false);
|
||||
} elseif ($now->lt($to)) {
|
||||
// After midnight, before 'to'
|
||||
return (int) $now->diffInSeconds($to, false);
|
||||
} else {
|
||||
// Not in sleep window
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Overnight range
|
||||
if ($now->gte($from)) {
|
||||
// After 'from', before midnight
|
||||
return (int) $now->diffInSeconds($to->copy()->addDay(), false);
|
||||
}
|
||||
if ($now->lt($to)) {
|
||||
// After midnight, before 'to'
|
||||
return (int) $now->diffInSeconds($to, false);
|
||||
}
|
||||
|
||||
// Not in sleep window
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public function isPauseActive(): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue