]> _ Git - songbook.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 10 Sep 2022 16:25:21 +0000 (18:25 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 10 Sep 2022 16:25:21 +0000 (18:25 +0200)
app/Http/Controllers/FrontController.php
public/.htaccess

index 66e00a12ea7a2a837b2ef3b568a3bcfec508ae7e..ba72d9d871bace22835b21956801be28c47a36ad 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\Collection;
+use App\Models\CollectionList;
 use App\Models\Song;
 use Cubist\Backpack\Http\Controllers\CubistPWAController;
 
@@ -21,8 +22,10 @@ class FrontController extends Controller
         if (null === $collection) {
             return self::defaultCollection();
         }
-        $songs = $this->_getSongsOfCollection($collection->id);
-        return view('collection', ['songs' => $songs, 'collection' => $collection, 'collection_songs' => $songs]);
+        $lists = CollectionList::where('collection', $collection->id)->get();
+        $songs = $this->_getSongsOfCollection($collection->id, $lists);
+
+        return view('collection', ['songs' => $songs, 'collection' => $collection, 'collection_songs' => $songs, 'collection_lists' => $lists]);
     }
 
     public function song($collection, $song)
@@ -35,13 +38,19 @@ class FrontController extends Controller
         if (null === $song) {
             abort(404);
         }
-        $collectionSongs = Song::whereRaw('json_contains(collections, \'["' . $collection->id . '"]\')')->get();
-        return view('song', ['song' => $song, 'collection' => $collection, 'collection_songs' => $this->_getSongsOfCollection($collection->id)]);
+        $lists = CollectionList::where('collection', $collection->id)->get();
+        return view('song', ['song' => $song, 'collection' => $collection, 'collection_songs' => $this->_getSongsOfCollection($collection->id, $lists), 'collection_lists' => $lists]);
     }
 
-    protected function _getSongsOfCollection($id)
+    protected function _getSongsOfCollection($id, $lists)
     {
-        return Song::whereRaw('json_contains(collections, \'["' . $id . '"]\')')->orderBy('title')->get();
+        /** @var Song $q */
+        $q = Song::whereRaw('json_contains(collections, \'["' . $id . '"]\')');
+        foreach ($lists as $list) {
+            $q->orWhereRaw('json_contains(collections, \'["' . $id . '_' . $list->id . '"]\')');
+        }
+        return $q->orderBy('title')->get();
+
     }
 
     public function manifest($collection)
@@ -64,7 +73,7 @@ class FrontController extends Controller
         $icons[count($icons) - 1]['purpose'] = 'maskable';
 
         $res = ['name' => $collection->name,
-            'short_name' => $collection->shortname?:$collection->name,
+            'short_name' => $collection->shortname ?: $collection->name,
             'description' => '',
             'display' => 'standalone',
             'orientation' => 'any',
index 3aec5e27e5db801fa9e321c0a97acbb49e10908f..8046faab6992496259d604aec532f488a242383e 100644 (file)
@@ -9,6 +9,8 @@
     RewriteCond %{HTTP:Authorization} .
     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 
+    RewriteRule ^rodadocavaco-2021(.*)$ /rodadocavaco/$1 [L,R=308]
+
     # Redirect Trailing Slashes If Not A Folder...
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_URI} (.+)/$