diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 442dcf9..72fc0cc 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -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')); + } } diff --git a/resources/views/user/base.blade.php b/resources/views/user/base.blade.php index 0f618f9..ee33db5 100644 --- a/resources/views/user/base.blade.php +++ b/resources/views/user/base.blade.php @@ -20,6 +20,11 @@ + @if ($user->isMe()) + + @endif
@yield('tab-content') diff --git a/resources/views/user/likes.blade.php b/resources/views/user/likes.blade.php new file mode 100644 index 0000000..7c78f50 --- /dev/null +++ b/resources/views/user/likes.blade.php @@ -0,0 +1,25 @@ +@extends('user.base') + +@section('title', $user->display_name . ' (@' . $user->name . ') さんがいいねしたチェックイン') + +@section('tab-content') +@if ($user->is_protected && !$user->isMe()) +

+ このユーザはいいね一覧を公開していません。 +

+@else + + {{ $likes->links(null, ['className' => 'mt-4 justify-content-center']) }} +@endif +@endsection diff --git a/routes/web.php b/routes/web.php index 23eca8e..6eba7e1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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 () {