Merge photo comments feature #114

Merged
aheathershaw merged 28 commits from feature/4-commenting-on-photos into master 2018-10-05 23:37:26 +01:00
6 changed files with 37 additions and 11 deletions
Showing only changes of commit 1f7befafab - Show all commits

View File

@ -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', [

View File

@ -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');
}
}

View File

@ -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
</div>

View File

@ -1,10 +0,0 @@
<div class="row">
<div class="col mt-4">
<h2>@lang('gallery.photo_comments_heading')</h2>
<h3>@lang('gallery.photo_comments_reply_form_heading')</h3>
<p>@lang('gallery.photo_comments_reply_form_p1')</p>
<hr/>
@include(Theme::viewName('gallery.photo_comments_reply_form'))
</div>
</div>

View File

@ -0,0 +1,21 @@
<div class="row">
<div class="col mt-4">
<h2>@lang('gallery.photo_comments_heading')</h2>
<h3>@lang('gallery.photo_comments_reply_form_heading')</h3>
<p>@lang('gallery.photo_comments_reply_form_p1')</p>
<hr/>
@include(Theme::viewName('partials.photo_comments_reply_form'))
@if ($photo->approvedComments()->count() > 0)
<ul>
@foreach ($photo->approvedComments as $comment)
<li>
Comment by <b>{{ $comment->createdBy->name }}</b>:<br/>
{{ $comment->comment_text }}
</li>
@endforeach
</ul>
@endif
</div>
</div>