diff --git a/app/Photo.php b/app/Photo.php index bf224ff..37e90a6 100644 --- a/app/Photo.php +++ b/app/Photo.php @@ -52,6 +52,11 @@ class Photo extends Model return $this->belongsTo(Album::class); } + public function approvedComments() + { + return $this->hasMany(PhotoComment::class)->whereNotNull('approved_at'); + } + public function exifUrl() { return route('viewExifData', [ diff --git a/app/PhotoComment.php b/app/PhotoComment.php index 293b477..dec829a 100644 --- a/app/PhotoComment.php +++ b/app/PhotoComment.php @@ -16,4 +16,14 @@ class PhotoComment extends Model 'commentor_email', 'comment_text' ]; + + public function approvedBy() + { + return $this->belongsTo(User::class, 'approved_user_id'); + } + + public function createdBy() + { + return $this->belongsTo(User::class, 'created_user_id'); + } } \ No newline at end of file diff --git a/resources/views/themes/base/gallery/photo.blade.php b/resources/views/themes/base/gallery/photo.blade.php index 61fcc74..d945288 100644 --- a/resources/views/themes/base/gallery/photo.blade.php +++ b/resources/views/themes/base/gallery/photo.blade.php @@ -57,7 +57,7 @@ @endif @if (UserConfig::get('allow_photo_comments')) - @include (Theme::viewName('partials.gallery_photo_comments')) + @include (Theme::viewName('partials.photo_comments')) @endif diff --git a/resources/views/themes/base/partials/gallery_photo_comments.blade.php b/resources/views/themes/base/partials/gallery_photo_comments.blade.php deleted file mode 100644 index 0f553c3..0000000 --- a/resources/views/themes/base/partials/gallery_photo_comments.blade.php +++ /dev/null @@ -1,10 +0,0 @@ -
-
-

@lang('gallery.photo_comments_heading')

- -

@lang('gallery.photo_comments_reply_form_heading')

-

@lang('gallery.photo_comments_reply_form_p1')

-
- @include(Theme::viewName('gallery.photo_comments_reply_form')) -
-
\ No newline at end of file diff --git a/resources/views/themes/base/partials/photo_comments.blade.php b/resources/views/themes/base/partials/photo_comments.blade.php new file mode 100644 index 0000000..d4a9445 --- /dev/null +++ b/resources/views/themes/base/partials/photo_comments.blade.php @@ -0,0 +1,21 @@ +
+
+

@lang('gallery.photo_comments_heading')

+ +

@lang('gallery.photo_comments_reply_form_heading')

+

@lang('gallery.photo_comments_reply_form_p1')

+
+ @include(Theme::viewName('partials.photo_comments_reply_form')) + + @if ($photo->approvedComments()->count() > 0) + + @endif +
+
\ No newline at end of file diff --git a/resources/views/themes/base/gallery/photo_comments_reply_form.blade.php b/resources/views/themes/base/partials/photo_comments_reply_form.blade.php similarity index 100% rename from resources/views/themes/base/gallery/photo_comments_reply_form.blade.php rename to resources/views/themes/base/partials/photo_comments_reply_form.blade.php