チェックイン単独のページを追加

This commit is contained in:
shibafu
2017-11-05 21:49:27 +09:00
parent fca4c21d3a
commit d0c9e3a3af
4 changed files with 118 additions and 3 deletions

View File

@@ -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()