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

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

View File

@ -0,0 +1,97 @@
@extends('layouts.base')
@section('content')
<div class="container">
<div class="row">
<div class="col-lg-4">
@component('components.profile', ['user' => $user])
@endcomponent
</div>
<div class="col-lg-8">
@if ($ejaculation->is_private && !(Auth::check() && $user->id === Auth::user()->id))
<div class="card">
<div class="card-body">
<span class="oi oi-lock-locked"></span> 非公開チェックインのため、表示できません
</div>
</div>
@else
<div class="card">
<div class="card-body">
<!-- span -->
<div class="d-flex justify-content-between">
<h5>{{ $ejaculatedSpan ?? '精通' }} <small class="text-muted">{{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}</small></h5>
@if (Auth::check() && $user->id === Auth::user()->id)
<div>
<a class="text-secondary timeline-action-item" href="#"><span class="oi oi-pencil" data-toggle="tooltip" data-placement="bottom" title="修正"></span></a>
<a class="text-secondary timeline-action-item" href="#" data-toggle="modal" data-target="#deleteCheckinModal" data-id="{{ $ejaculation->id }}" data-date="{{ $ejaculation->ejaculated_date }}"><span class="oi oi-trash" data-toggle="tooltip" data-placement="bottom" title="削除"></span></a>
</div>
@endif
</div>
<!-- tags -->
@if ($ejaculation->is_private) {{-- TODO: タグを付けたら、タグが空じゃないかも判定に加える --}}
<p class="mb-2">
@if ($ejaculation->is_private)
<span class="badge badge-warning"><span class="oi oi-lock-locked"></span> 非公開</span>
@endif
{{--
<span class="badge badge-secondary"><span class="oi oi-tag"></span> 催眠音声</span>
<span class="badge badge-secondary"><span class="oi oi-tag"></span> 適当なタグ</span>
--}}
</p>
@endif
<!-- okazu link -->
{{--
<div class="card mb-2 w-50" style="font-size: small;">
<a class="text-dark card-link" href="#">
<img src="holder.js/320x240" alt="Thumbnail" class="card-img-top">
<div class="card-body">
<h6 class="card-title">タイトル</h6>
<p class="card-text">コンテンツの説明文</p>
</div>
</a>
</div>
--}}
<!-- note -->
@if (!empty($ejaculation->note))
<p class="mb-0 tis-word-wrap">
{!! Formatter::linkify(nl2br(e($ejaculation->note))) !!}
</p>
@endif
</div>
</div>
@endif
</div>
</div>
</div>
@component('components.modal', ['id' => 'deleteCheckinModal'])
@slot('title')
削除確認
@endslot
<span class="date-label"></span> のチェックインを削除してもよろしいですか?
<form action="{{ route('checkin.destroy', ['id' => '@']) }}" method="post">
{{ csrf_field() }}
{{ method_field('DELETE') }}
</form>
@slot('footer')
<button type="button" class="btn btn-secondary" data-dismiss="modal">キャンセル</button>
<button type="button" class="btn btn-danger">削除</button>
@endslot
@endcomponent
@endsection
@push('script')
<script>
$('#deleteCheckinModal').on('show.bs.modal', function (event) {
var target = $(event.relatedTarget);
var modal = $(this);
modal.find('.modal-body .date-label').text(target.data('date'));
modal.data('id', target.data('id'));
}).find('.btn-danger').on('click', function (event) {
var modal = $('#deleteCheckinModal');
var form = modal.find('form');
form.attr('action', form.attr('action').replace('@', modal.data('id')));
form.submit();
});
</script>
@endpush

View File

@ -6,7 +6,7 @@
<li class="list-group-item border-bottom-only pt-3 pb-3">
<!-- span -->
<div class="d-flex justify-content-between">
<h5>{{ $ejaculation->ejaculated_span ?? '精通' }} <small class="text-muted">{{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}</small></h5>
<h5>{{ $ejaculation->ejaculated_span ?? '精通' }} <a href="{{ route('checkin.show', ['id' => $ejaculation->id]) }}" class="text-muted"><small>{{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}</small></a></h5>
@if (Auth::check() && $user->id === Auth::user()->id)
<div>
<a class="text-secondary timeline-action-item" href="#"><span class="oi oi-pencil" data-toggle="tooltip" data-placement="bottom" title="修正"></span></a>

View File

@ -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');
});