From 94b2a9d1b653dae235e0163aa3a95c2e42873c26 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Mon, 17 Apr 2017 21:53:47 +0100 Subject: [PATCH] #4: Child album count is now included when using the Album::children() method. Child albums are now displayed in the gallery --- app/Album.php | 2 +- .../base/gallery/album_default.blade.php | 44 ++++++++++++++----- .../themes/base/gallery/album_empty.blade.php | 22 +++++++++- .../base/gallery/album_slideshow.blade.php | 25 +++++++++-- 4 files changed, 76 insertions(+), 17 deletions(-) diff --git a/app/Album.php b/app/Album.php index d8dd6a6..c586d87 100644 --- a/app/Album.php +++ b/app/Album.php @@ -58,7 +58,7 @@ class Album extends Model public function children() { - return $this->hasMany(Album::class, 'parent_album_id'); + return $this->hasMany(Album::class, 'parent_album_id')->withCount('photos'); } public function doesGroupHavePermission(Group $group, Permission $permission) diff --git a/resources/views/themes/base/gallery/album_default.blade.php b/resources/views/themes/base/gallery/album_default.blade.php index d34e6ef..5822a9a 100644 --- a/resources/views/themes/base/gallery/album_default.blade.php +++ b/resources/views/themes/base/gallery/album_default.blade.php @@ -1,6 +1,8 @@ @extends('themes.base.layout') @section('title', $album->name) +@php ($hasChildren = $album->children()->count() > 0) + @section('content')
@@ -22,24 +24,44 @@

{{ $album->name }}

{{ $album->description }}

+

- @foreach ($photos as $photo) -
-
- -
-

{{ $photo->name }}

+
+
+ @foreach ($photos as $photo) +
+
+ + + +
- -
+ @endforeach
- @endforeach +
+ @if ($hasChildren) +
+ @foreach ($album->children as $childAlbum) +
+ + + +
+ @endforeach +
+ @endif
diff --git a/resources/views/themes/base/gallery/album_empty.blade.php b/resources/views/themes/base/gallery/album_empty.blade.php index 82fd590..2878fd5 100644 --- a/resources/views/themes/base/gallery/album_empty.blade.php +++ b/resources/views/themes/base/gallery/album_empty.blade.php @@ -1,6 +1,8 @@ @extends('themes.base.layout') @section('title', $album->name) +@php ($hasChildren = $album->children()->count() > 0) + @section('content')
@@ -13,15 +15,31 @@
-
+
-
+

@lang('gallery.album_no_results_heading')

@lang('gallery.album_no_results_text', ['admin_link' => sprintf('%s', route('admin'), trans('admin.title'))])

@lang('gallery.album_no_results_text_2')

+ + @if ($hasChildren) +
+ @foreach ($album->children as $childAlbum) +
+ + + +
+ @endforeach +
+ @endif
@endsection \ No newline at end of file diff --git a/resources/views/themes/base/gallery/album_slideshow.blade.php b/resources/views/themes/base/gallery/album_slideshow.blade.php index 06499c1..c8e234c 100644 --- a/resources/views/themes/base/gallery/album_slideshow.blade.php +++ b/resources/views/themes/base/gallery/album_slideshow.blade.php @@ -9,19 +9,20 @@ @section('content')
-
+
@include(\App\Facade\Theme::viewName('partials.album_view_selector'))

{{ $album->name }}

{{ $album->description }}

+

-
+
@@ -38,7 +39,7 @@
-
+
@foreach ($photos as $photo) @@ -48,6 +49,24 @@
+ +
@endsection