diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index 78ba14d..b671e50 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -42,9 +42,26 @@ class EjaculationController extends Controller return redirect()->route('home')->with('status', 'チェックインしました!'); } - public function show() + public function show($id) { - // TODO: not implemented + $ejaculation = Ejaculation::findOrFail($id); + $user = User::findOrFail($ejaculation->user_id); + + // 1つ前のチェックインからの経過時間を求める + $previousEjaculation = Ejaculation::select('ejaculated_date') + ->where('user_id', $ejaculation->user_id) + ->where('ejaculated_date', '<', $ejaculation->ejaculated_date) + ->orderByDesc('ejaculated_date') + ->first(); + if (!empty($previousEjaculation)) { + $ejaculatedSpan = $ejaculation->ejaculated_date + ->diff($previousEjaculation->ejaculated_date) + ->format('%a日 %h時間 %i分'); + } else { + $ejaculatedSpan = null; + } + + return view('ejaculation.show')->with(compact('user', 'ejaculation', 'ejaculatedSpan')); } public function edit() diff --git a/resources/views/ejaculation/show.blade.php b/resources/views/ejaculation/show.blade.php new file mode 100644 index 0000000..37b3311 --- /dev/null +++ b/resources/views/ejaculation/show.blade.php @@ -0,0 +1,97 @@ +@extends('layouts.base') + +@section('content') +
+
+
+ @component('components.profile', ['user' => $user]) + @endcomponent +
+
+ @if ($ejaculation->is_private && !(Auth::check() && $user->id === Auth::user()->id)) +
+
+ 非公開チェックインのため、表示できません +
+
+ @else +
+
+ +
+
{{ $ejaculatedSpan ?? '精通' }} {{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
+ @if (Auth::check() && $user->id === Auth::user()->id) +
+ + +
+ @endif +
+ + @if ($ejaculation->is_private) {{-- TODO: タグを付けたら、タグが空じゃないかも判定に加える --}} +

+ @if ($ejaculation->is_private) + 非公開 + @endif + {{-- + 催眠音声 + 適当なタグ + --}} +

+ @endif + + {{-- + + --}} + + @if (!empty($ejaculation->note)) +

+ {!! Formatter::linkify(nl2br(e($ejaculation->note))) !!} +

+ @endif +
+
+ @endif +
+
+
+ +@component('components.modal', ['id' => 'deleteCheckinModal']) + @slot('title') + 削除確認 + @endslot + のチェックインを削除してもよろしいですか? +
+ {{ csrf_field() }} + {{ method_field('DELETE') }} +
+ @slot('footer') + + + @endslot +@endcomponent +@endsection + +@push('script') + +@endpush \ No newline at end of file diff --git a/resources/views/user/profile.blade.php b/resources/views/user/profile.blade.php index 296fde1..d76cef6 100644 --- a/resources/views/user/profile.blade.php +++ b/resources/views/user/profile.blade.php @@ -6,7 +6,7 @@
  • -
    {{ $ejaculation->ejaculated_span ?? '精通' }} {{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
    +
    {{ $ejaculation->ejaculated_span ?? '精通' }} {{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
    @if (Auth::check() && $user->id === Auth::user()->id)
    diff --git a/routes/web.php b/routes/web.php index 704bc30..0619786 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,6 +25,7 @@ Route::get('/user/{name}/okazu', 'UserController@okazu')->name('user.okazu'); Route::middleware('auth')->group(function () { Route::get('/checkin', 'EjaculationController@create')->name('checkin'); Route::post('/checkin', 'EjaculationController@store')->name('checkin'); + Route::get('/checkin/{id}', 'EjaculationController@show')->name('checkin.show'); Route::delete('/checkin/{id}', 'EjaculationController@destroy')->name('checkin.destroy'); });