いいねしたユーザーの一覧を表示
This commit is contained in:
parent
2cd09402d1
commit
4ed2a9048d
@ -46,14 +46,23 @@ class Ejaculation extends Model
|
|||||||
{
|
{
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
// (ejaculation_id, user_id) でユニークなわけですが、サブクエリ発行させるのとLeft JoinしてNULLかどうかで結果を見るのどっちがいいんでしょうね
|
// (ejaculation_id, user_id) でユニークなわけですが、サブクエリ発行させるのとLeft JoinしてNULLかどうかで結果を見るのどっちがいいんでしょうね
|
||||||
return $query->withCount([
|
return $query
|
||||||
'likes',
|
->with(['likes.user' => function ($query) {
|
||||||
'likes as is_liked' => function ($query) {
|
$query->where('is_protected', false)
|
||||||
$query->where('user_id', Auth::id());
|
->orWhere('id', Auth::id());
|
||||||
}
|
}])
|
||||||
]);
|
->withCount([
|
||||||
|
'likes',
|
||||||
|
'likes as is_liked' => function ($query) {
|
||||||
|
$query->where('user_id', Auth::id());
|
||||||
|
}
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
return $query->withCount('likes')
|
return $query
|
||||||
|
->with(['likes.user' => function ($query) {
|
||||||
|
$query->where('is_protected', false);
|
||||||
|
}])
|
||||||
|
->withCount('likes')
|
||||||
->addSelect('0 as is_liked');
|
->addSelect('0 as is_liked');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
resources/assets/sass/app.scss
vendored
4
resources/assets/sass/app.scss
vendored
@ -26,4 +26,8 @@ $primary: #e53fb1;
|
|||||||
|
|
||||||
.like-count:not(:empty) {
|
.like-count:not(:empty) {
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.like-users {
|
||||||
|
height: 30px;
|
||||||
}
|
}
|
@ -29,6 +29,19 @@
|
|||||||
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
<!-- likes -->
|
||||||
|
@if ($ejaculation->likes_count > 0)
|
||||||
|
<div class="my-2 py-1 border-top border-bottom d-flex align-items-center">
|
||||||
|
<div class="ml-2 mr-3 text-secondary"><span class="oi oi-heart" title="いいねしたユーザー"></span></div>
|
||||||
|
<div class="like-users flex-grow-1 overflow-hidden">
|
||||||
|
@foreach ($ejaculation->likes as $like)
|
||||||
|
@if ($like->user !== null)
|
||||||
|
<a href="{{ route('user.profile', ['name' => $like->user->name]) }}"><img src="{{ $like->user->getProfileImageUrl(30) }}" width="30" height="30" class="rounded" data-toggle="tooltip" data-placement="bottom" title="{{ $like->user->display_name }}"></a>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<!-- actions -->
|
<!-- actions -->
|
||||||
<div class="ejaculation-actions">
|
<div class="ejaculation-actions">
|
||||||
<button type="button" class="btn btn-link text-secondary"
|
<button type="button" class="btn btn-link text-secondary"
|
||||||
|
@ -60,6 +60,19 @@
|
|||||||
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
<!-- likes -->
|
||||||
|
@if ($ejaculation->likes_count > 0)
|
||||||
|
<div class="my-2 py-1 border-top border-bottom d-flex align-items-center">
|
||||||
|
<div class="ml-2 mr-3 text-secondary"><span class="oi oi-heart" title="いいねしたユーザー"></span></div>
|
||||||
|
<div class="like-users flex-grow-1 overflow-hidden">
|
||||||
|
@foreach ($ejaculation->likes as $like)
|
||||||
|
@if ($like->user !== null)
|
||||||
|
<a href="{{ route('user.profile', ['name' => $like->user->name]) }}"><img src="{{ $like->user->getProfileImageUrl(30) }}" width="30" height="30" class="rounded" data-toggle="tooltip" data-placement="bottom" title="{{ $like->user->display_name }}"></a>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<!-- actions -->
|
<!-- actions -->
|
||||||
<div class="ejaculation-actions">
|
<div class="ejaculation-actions">
|
||||||
<button type="button" class="btn btn-link text-secondary" data-toggle="tooltip" data-placement="bottom" title="同じオカズでチェックイン" data-href="{{ route('checkin', ['link' => $ejaculation->link, 'tags' => $ejaculation->textTags()]) }}"><span class="oi oi-reload"></span></button>
|
<button type="button" class="btn btn-link text-secondary" data-toggle="tooltip" data-placement="bottom" title="同じオカズでチェックイン" data-href="{{ route('checkin', ['link' => $ejaculation->link, 'tags' => $ejaculation->textTags()]) }}"><span class="oi oi-reload"></span></button>
|
||||||
|
@ -66,6 +66,19 @@
|
|||||||
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
<!-- likes -->
|
||||||
|
@if ($ejaculation->likes_count > 0)
|
||||||
|
<div class="my-2 py-1 border-top border-bottom d-flex align-items-center">
|
||||||
|
<div class="ml-2 mr-3 text-secondary"><span class="oi oi-heart" title="いいねしたユーザー"></span></div>
|
||||||
|
<div class="like-users flex-grow-1 overflow-hidden">
|
||||||
|
@foreach ($ejaculation->likes as $like)
|
||||||
|
@if ($like->user !== null)
|
||||||
|
<a href="{{ route('user.profile', ['name' => $like->user->name]) }}"><img src="{{ $like->user->getProfileImageUrl(30) }}" width="30" height="30" class="rounded" data-toggle="tooltip" data-placement="bottom" title="{{ $like->user->display_name }}"></a>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<!-- actions -->
|
<!-- actions -->
|
||||||
<div class="ejaculation-actions">
|
<div class="ejaculation-actions">
|
||||||
<button type="button" class="btn btn-link text-secondary" data-toggle="tooltip" data-placement="bottom" title="同じオカズでチェックイン" data-href="{{ route('checkin', ['link' => $ejaculation->link, 'tags' => $ejaculation->textTags()]) }}"><span class="oi oi-reload"></span></button>
|
<button type="button" class="btn btn-link text-secondary" data-toggle="tooltip" data-placement="bottom" title="同じオカズでチェックイン" data-href="{{ route('checkin', ['link' => $ejaculation->link, 'tags' => $ejaculation->textTags()]) }}"><span class="oi oi-reload"></span></button>
|
||||||
|
Loading…
Reference in New Issue
Block a user