mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: add plugin model
initial implementation of playlist feat: added support for playlists
This commit is contained in:
parent
276511fc98
commit
4195269414
17 changed files with 669 additions and 15 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
|
|
@ -50,4 +51,29 @@ class Device extends Model
|
|||
return 3; // Strong signal (3 bars)
|
||||
}
|
||||
}
|
||||
|
||||
public function playlists(): HasMany
|
||||
{
|
||||
return $this->hasMany(Playlist::class);
|
||||
}
|
||||
|
||||
public function getNextPlaylistItem(): ?PlaylistItem
|
||||
{
|
||||
// Get all active playlists
|
||||
$playlists = $this->playlists()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
// Find the first active playlist with an available item
|
||||
foreach ($playlists as $playlist) {
|
||||
if ($playlist->isActiveNow()) {
|
||||
$nextItem = $playlist->getNextPlaylistItem();
|
||||
if ($nextItem) {
|
||||
return $nextItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue