devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); return view('livewire.playlists.index'); } public function togglePlaylistActive(Playlist $playlist) { abort_unless(auth()->user()->devices->contains($playlist->device), 403); $playlist->update(['is_active' => !$playlist->is_active]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } public function movePlaylistItemUp(PlaylistItem $item) { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $previousItem = $item->playlist->items() ->where('order', '<', $item->order) ->orderBy('order', 'desc') ->first(); if ($previousItem) { $tempOrder = $previousItem->order; $previousItem->update(['order' => $item->order]); $item->update(['order' => $tempOrder]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } } public function movePlaylistItemDown(PlaylistItem $item) { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $nextItem = $item->playlist->items() ->where('order', '>', $item->order) ->orderBy('order') ->first(); if ($nextItem) { $tempOrder = $nextItem->order; $nextItem->update(['order' => $item->order]); $item->update(['order' => $tempOrder]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } } public function togglePlaylistItemActive(PlaylistItem $item) { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $item->update(['is_active' => !$item->is_active]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } public function deletePlaylist(Playlist $playlist) { abort_unless(auth()->user()->devices->contains($playlist->device), 403); $playlist->delete(); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); Flux::modal('delete-playlist-' . $playlist->id)->close(); } public function deletePlaylistItem(PlaylistItem $item) { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $item->delete(); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); Flux::modal('delete-playlist-item-' . $item->id)->close(); } public function editPlaylist(Playlist $playlist) { abort_unless(auth()->user()->devices->contains($playlist->device), 403); $this->validate([ 'playlist_name' => 'required|string|max:255', 'selected_weekdays' => 'nullable|array', 'active_from' => 'nullable|date_format:H:i', 'active_until' => 'nullable|date_format:H:i', 'refresh_time' => 'nullable|integer|min:60', ]); if ($this->refresh_time < 60) { $this->refresh_time = null; } if (empty($this->selected_weekdays)){ $this->selected_weekdays = null; } $playlist->update([ 'name' => $this->playlist_name, 'weekdays' => $this->selected_weekdays, 'active_from' => $this->active_from, 'active_until' => $this->active_until, 'refresh_time' => $this->refresh_time, ]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); $this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until', 'refresh_time']); Flux::modal('edit-playlist-' . $playlist->id)->close(); } public function preparePlaylistEdit(Playlist $playlist) { $this->playlist_name = $playlist->name; $this->selected_weekdays = $playlist->weekdays ?? null; $this->active_from = optional($playlist->active_from)->format('H:i'); $this->active_until = optional($playlist->active_until)->format('H:i'); $this->refresh_time = $playlist->refresh_time; } }; ?>

Playlists

@foreach($devices as $device) @if($device->playlists->isNotEmpty())

{{ $device->name }}

@foreach($device->playlists as $playlist)

{{ $playlist->name }}

@if($playlist->weekdays) {{ implode(', ', collect($playlist->weekdays)->map(fn($day) => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][$day])->toArray()) }} @endif @if($playlist->active_from && $playlist->active_until) {{ $playlist->active_from->format('H:i') }} - {{ $playlist->active_until->format('H:i') }} @endif
@foreach($playlist->items->sortBy('order') as $item) @endforeach
Plugin / Recipe
Status
Actions
@if($item->isMashup())
{{ $item->getMashupName() }}
{{ collect($item->getMashupPluginIds())->map(fn($id) => App\Models\Plugin::find($id)->name)->join(' | ') }}
@else
{{ $item->plugin->name }}
@endif
@if($playlist->items->count() > 1) @if(!$loop->first) @endif @if(!$loop->last) @endif @endif
@if($item->isMashup()) Delete {{ $item->getMashupName() }}? @else Delete {{ $item->plugin->name }}? @endif

@if($item->isMashup()) This will remove this mashup from the playlist. @else This will remove this item from the playlist. @endif

Cancel Delete item
Edit Playlist
Save Changes
Delete {{ $playlist->name }}?

This will permanently delete this playlist and all its items.

Cancel Delete playlist
@endforeach
@endif @endforeach @if($devices->isEmpty() || $devices->every(fn($device) => $device->playlists->isEmpty()))

No playlists found

Add playlists to your devices to see them here.

@if($devices->isNotEmpty()) Go to Devices @else Add Device @endif
@endif