いいね一覧の追加

This commit is contained in:
shibafu 2019-04-06 00:14:05 +09:00
parent 02f03165d6
commit fe880ee599
4 changed files with 50 additions and 0 deletions

View File

@ -177,4 +177,23 @@ SQL
return view('user.profile')->with(compact('user', 'ejaculations'));
}
public function likes($name)
{
$user = User::where('name', $name)->first();
if (empty($user)) {
abort(404);
}
if (!$user->isMe()) {
abort(403);
}
$likes = $user->likes()
->orderBy('created_at', 'desc')
->with('ejaculation.user', 'ejaculation.tags')
->paginate(20);
return view('user.likes')->with(compact('user', 'likes'));
}
}

View File

@ -20,6 +20,11 @@
<li class="nav-item">
<a class="nav-link {{ Route::currentRouteName() === 'user.okazu' ? 'active' : '' }}" href="{{ route('user.okazu', ['name' => $user->name]) }}">オカズ</a>
</li>
@if ($user->isMe())
<li class="nav-item">
<a class="nav-link {{ Route::currentRouteName() === 'user.likes' ? 'active' : '' }}" href="{{ route('user.likes', ['name' => $user->name]) }}">いいね <span class="badge badge-primary">{{ $user->likes()->count() }}</span></a>
</li>
@endif
</ul>
<div class="tab-content">
@yield('tab-content')

View File

@ -0,0 +1,25 @@
@extends('user.base')
@section('title', $user->display_name . ' (@' . $user->name . ') さんがいいねしたチェックイン')
@section('tab-content')
@if ($user->is_protected && !$user->isMe())
<p class="mt-4">
<span class="oi oi-lock-locked"></span> このユーザはいいね一覧を公開していません。
</p>
@else
<ul class="list-group">
@forelse ($likes as $like)
<li class="list-group-item border-bottom-only pt-3 pb-3 text-break">
@component('components.ejaculation', ['ejaculation' => $like->ejaculation])
@endcomponent
</li>
@empty
<li class="list-group-item border-bottom-only">
<p>まだ何もいいと思ったことがありません。</p>
</li>
@endforelse
</ul>
{{ $likes->links(null, ['className' => 'mt-4 justify-content-center']) }}
@endif
@endsection

View File

@ -19,6 +19,7 @@ Route::get('/user', 'UserController@redirectMypage')->middleware('auth');
Route::get('/user/{name?}', 'UserController@profile')->name('user.profile');
Route::get('/user/{name}/stats', 'UserController@stats')->name('user.stats');
Route::get('/user/{name}/okazu', 'UserController@okazu')->name('user.okazu');
Route::get('/user/{name}/likes', 'UserController@likes')->name('user.likes');
Route::get('/checkin/{id}', 'EjaculationController@show')->name('checkin.show');
Route::middleware('auth')->group(function () {