@@ -36,6 +36,31 @@ class HomeController extends Controller
 | 
			
		||||
        $categories = Information::CATEGORIES;
 | 
			
		||||
 | 
			
		||||
        if (Auth::check()) {
 | 
			
		||||
            // チェックイン動向グラフ用のデータ取得
 | 
			
		||||
            $groupByDay = Ejaculation::select(DB::raw(
 | 
			
		||||
                <<<'SQL'
 | 
			
		||||
to_char(ejaculated_date, 'YYYY/MM/DD') AS "date",
 | 
			
		||||
count(*) AS "count"
 | 
			
		||||
SQL
 | 
			
		||||
            ))
 | 
			
		||||
                ->join('users', function ($join) {
 | 
			
		||||
                    $join->on('users.id', '=', 'ejaculations.user_id')
 | 
			
		||||
                        ->where('users.accept_analytics', true);
 | 
			
		||||
                })
 | 
			
		||||
                ->where('ejaculated_date', '>=', now()->subDays(14))
 | 
			
		||||
                ->groupBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')"))
 | 
			
		||||
                ->orderBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')"))
 | 
			
		||||
                ->get()
 | 
			
		||||
                ->mapWithKeys(function ($item) {
 | 
			
		||||
                    return [$item['date'] => $item['count']];
 | 
			
		||||
                });
 | 
			
		||||
            $globalEjaculationCounts = [];
 | 
			
		||||
            $day = Carbon::now()->subDays(29);
 | 
			
		||||
            for ($i = 0; $i < 30; $i++) {
 | 
			
		||||
                $globalEjaculationCounts[$day->format('Y/m/d') . ' の総チェックイン数'] = $groupByDay[$day->format('Y/m/d')] ?? 0;
 | 
			
		||||
                $day->addDay();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // お惣菜コーナー用のデータ取得
 | 
			
		||||
            $publicLinkedEjaculations = Ejaculation::join('users', 'users.id', '=', 'ejaculations.user_id')
 | 
			
		||||
                ->where('users.is_protected', false)
 | 
			
		||||
@@ -47,7 +72,7 @@ class HomeController extends Controller
 | 
			
		||||
                ->take(10)
 | 
			
		||||
                ->get();
 | 
			
		||||
 | 
			
		||||
            return view('home')->with(compact('informations', 'categories', 'publicLinkedEjaculations'));
 | 
			
		||||
            return view('home')->with(compact('informations', 'categories', 'globalEjaculationCounts', 'publicLinkedEjaculations'));
 | 
			
		||||
        } else {
 | 
			
		||||
            return view('guest')->with(compact('informations', 'categories'));
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								public/css/tissue.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								public/css/tissue.css
									
									
									
									
										vendored
									
									
								
							@@ -24,6 +24,16 @@
 | 
			
		||||
    transition: filter .15s liner;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.list-group-item.no-side-border {
 | 
			
		||||
    border-left: none;
 | 
			
		||||
    border-right: none;
 | 
			
		||||
    border-radius: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.list-group-item.border-bottom-only:first-child {
 | 
			
		||||
    border-top: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.list-group-item.border-bottom-only {
 | 
			
		||||
    border-left: none;
 | 
			
		||||
    border-right: none;
 | 
			
		||||
@@ -37,3 +47,14 @@
 | 
			
		||||
.timeline-action-item {
 | 
			
		||||
    margin-left: 16px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.tis-global-count-graph {
 | 
			
		||||
    height: 90px;
 | 
			
		||||
    border-bottom: 1px solid rgba(0, 0, 0, .125);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@media (min-width: 992px) {
 | 
			
		||||
    .tis-sidebar-info {
 | 
			
		||||
        font-size: small;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								public/js/tissue.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								public/js/tissue.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
// app.jsの名はモジュールバンドラーを投入する日まで予約しておく。CSSも同じ。
 | 
			
		||||
 | 
			
		||||
(function ($) {
 | 
			
		||||
 | 
			
		||||
    $.fn.linkCard = function (options) {
 | 
			
		||||
        var settings = $.extend({
 | 
			
		||||
            endpoint: '/api/checkin/card'
 | 
			
		||||
        }, options);
 | 
			
		||||
 | 
			
		||||
        return this.each(function () {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: settings.endpoint,
 | 
			
		||||
                method: 'get',
 | 
			
		||||
                type: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    url: $this.find('a').attr('href')
 | 
			
		||||
                }
 | 
			
		||||
            }).then(function (data) {
 | 
			
		||||
                var $title = $this.find('.card-title');
 | 
			
		||||
                var $desc = $this.find('.card-text');
 | 
			
		||||
                var $image = $this.find('img');
 | 
			
		||||
 | 
			
		||||
                if (data.title === '') {
 | 
			
		||||
                    $title.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $title.text(data.title);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.description === '') {
 | 
			
		||||
                    $desc.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $desc.text(data.description);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.image === '') {
 | 
			
		||||
                    $image.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $image.attr('src', data.image);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.title !== '' || data.description !== '' || data.image !== '') {
 | 
			
		||||
                    $this.removeClass('d-none');
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
})(jQuery);
 | 
			
		||||
@@ -112,42 +112,8 @@
 | 
			
		||||
            form.submit();
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $('.link-card').each(function () {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: '{{ url('/api/checkin/card') }}',
 | 
			
		||||
                method: 'get',
 | 
			
		||||
                type: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    url: $this.find('a').attr('href')
 | 
			
		||||
                }
 | 
			
		||||
            }).then(function (data) {
 | 
			
		||||
                var $title = $this.find('.card-title');
 | 
			
		||||
                var $desc = $this.find('.card-text');
 | 
			
		||||
                var $image = $this.find('img');
 | 
			
		||||
 | 
			
		||||
                if (data.title === '') {
 | 
			
		||||
                    $title.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $title.text(data.title);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.description === '') {
 | 
			
		||||
                    $desc.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $desc.text(data.description);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.image === '') {
 | 
			
		||||
                    $image.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $image.attr('src', data.image);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.title !== '' || data.description !== '' || data.image !== '') {
 | 
			
		||||
                    $this.removeClass('d-none');
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        $('.link-card').linkCard({
 | 
			
		||||
            endpoint: '{{ url('/api/checkin/card') }}'
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
@endpush
 | 
			
		||||
@@ -27,11 +27,9 @@
 | 
			
		||||
                    @endcomponent
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="col-lg-8">
 | 
			
		||||
            <div class="card mb-4">
 | 
			
		||||
                <div class="card-header">サイトからのお知らせ</div>
 | 
			
		||||
                <div class="list-group list-group-flush">
 | 
			
		||||
                <div class="list-group list-group-flush tis-sidebar-info">
 | 
			
		||||
                    @foreach($informations as $info)
 | 
			
		||||
                        <a class="list-group-item" href="{{ route('info.show', ['id' => $info->id]) }}">
 | 
			
		||||
                            @if ($info->pinned)
 | 
			
		||||
@@ -43,15 +41,20 @@
 | 
			
		||||
                    <a href="{{ route('info') }}" class="list-group-item text-right">お知らせ一覧 »</a>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            @if (!empty($publicLinkedEjaculations))
 | 
			
		||||
                <div class="card mb-4">
 | 
			
		||||
                    <div class="card-header">お惣菜コーナー</div>
 | 
			
		||||
                    <div class="card-body">
 | 
			
		||||
                        <p class="card-text">最近の公開チェックインから、オカズリンク付きのものを表示しています。</p>
 | 
			
		||||
        </div>
 | 
			
		||||
                    <ul class="list-group list-group-flush">
 | 
			
		||||
        <div class="col-lg-8">
 | 
			
		||||
            @if (!empty($globalEjaculationCounts))
 | 
			
		||||
                <h5>チェックインの動向</h5>
 | 
			
		||||
                <div class="w-100 mb-4 position-relative tis-global-count-graph">
 | 
			
		||||
                    <canvas id="global-count-graph"></canvas>
 | 
			
		||||
                </div>
 | 
			
		||||
            @endif
 | 
			
		||||
            @if (!empty($publicLinkedEjaculations))
 | 
			
		||||
                <h5 class="mb-3">お惣菜コーナー</h5>
 | 
			
		||||
                <p class="text-secondary">最近の公開チェックインから、オカズリンク付きのものを表示しています。</p>
 | 
			
		||||
                <ul class="list-group">
 | 
			
		||||
                    @foreach ($publicLinkedEjaculations as $ejaculation)
 | 
			
		||||
                            <li class="list-group-item pt-3 pb-3">
 | 
			
		||||
                        <li class="list-group-item no-side-border pt-3 pb-3 tis-word-wrap">
 | 
			
		||||
                            <!-- span -->
 | 
			
		||||
                            <div class="d-flex justify-content-between">
 | 
			
		||||
                                <h5>
 | 
			
		||||
@@ -96,7 +99,6 @@
 | 
			
		||||
                        </li>
 | 
			
		||||
                    @endforeach
 | 
			
		||||
                </ul>
 | 
			
		||||
                </div>
 | 
			
		||||
            @endif
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
@@ -104,43 +106,43 @@
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@push('script')
 | 
			
		||||
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/chart.js@2.7.1/dist/Chart.min.js"></script>
 | 
			
		||||
    <script>
 | 
			
		||||
        $('.link-card').each(function () {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: '{{ url('/api/checkin/card') }}',
 | 
			
		||||
                method: 'get',
 | 
			
		||||
                type: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    url: $this.find('a').attr('href')
 | 
			
		||||
                }
 | 
			
		||||
            }).then(function (data) {
 | 
			
		||||
                var $title = $this.find('.card-title');
 | 
			
		||||
                var $desc = $this.find('.card-text');
 | 
			
		||||
                var $image = $this.find('img');
 | 
			
		||||
 | 
			
		||||
                if (data.title === '') {
 | 
			
		||||
                    $title.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $title.text(data.title);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.description === '') {
 | 
			
		||||
                    $desc.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $desc.text(data.description);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.image === '') {
 | 
			
		||||
                    $image.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $image.attr('src', data.image);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.title !== '' || data.description !== '' || data.image !== '') {
 | 
			
		||||
                    $this.removeClass('d-none');
 | 
			
		||||
                }
 | 
			
		||||
        $('.link-card').linkCard({
 | 
			
		||||
            endpoint: '{{ url('/api/checkin/card') }}'
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        new Chart(document.getElementById('global-count-graph').getContext('2d'), {
 | 
			
		||||
            type: 'bar',
 | 
			
		||||
            data: {
 | 
			
		||||
                labels: @json(array_keys($globalEjaculationCounts)),
 | 
			
		||||
                datasets: [{
 | 
			
		||||
                    data: @json(array_values($globalEjaculationCounts)),
 | 
			
		||||
                    backgroundColor: 'rgba(0, 0, 0, .1)',
 | 
			
		||||
                    borderColor: 'rgba(0, 0, 0, .25)',
 | 
			
		||||
                    borderWidth: 1
 | 
			
		||||
                }]
 | 
			
		||||
            },
 | 
			
		||||
            options: {
 | 
			
		||||
                maintainAspectRatio: false,
 | 
			
		||||
                legend: {
 | 
			
		||||
                    display: false
 | 
			
		||||
                },
 | 
			
		||||
                elements: {
 | 
			
		||||
                    line: {}
 | 
			
		||||
                },
 | 
			
		||||
                scales: {
 | 
			
		||||
                    xAxes: [{
 | 
			
		||||
                        display: false
 | 
			
		||||
                    }],
 | 
			
		||||
                    yAxes: [{
 | 
			
		||||
                        display: false,
 | 
			
		||||
                        ticks: {
 | 
			
		||||
                            beginAtZero: true
 | 
			
		||||
                        }
 | 
			
		||||
                    }]
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
@endpush
 | 
			
		||||
@@ -134,6 +134,7 @@
 | 
			
		||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
 | 
			
		||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{{ asset('js/bootstrap.min.js') }}"></script>
 | 
			
		||||
<script type="text/javascript" src="{{ asset('js/tissue.js') }}"></script>
 | 
			
		||||
<script>
 | 
			
		||||
    $(function(){
 | 
			
		||||
        @guest
 | 
			
		||||
 
 | 
			
		||||
@@ -80,42 +80,8 @@
 | 
			
		||||
 | 
			
		||||
@push('script')
 | 
			
		||||
    <script>
 | 
			
		||||
        $('.link-card').each(function () {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: '{{ url('/api/checkin/card') }}',
 | 
			
		||||
                method: 'get',
 | 
			
		||||
                type: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    url: $this.find('a').attr('href')
 | 
			
		||||
                }
 | 
			
		||||
            }).then(function (data) {
 | 
			
		||||
                var $title = $this.find('.card-title');
 | 
			
		||||
                var $desc = $this.find('.card-text');
 | 
			
		||||
                var $image = $this.find('img');
 | 
			
		||||
 | 
			
		||||
                if (data.title === '') {
 | 
			
		||||
                    $title.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $title.text(data.title);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.description === '') {
 | 
			
		||||
                    $desc.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $desc.text(data.description);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.image === '') {
 | 
			
		||||
                    $image.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $image.attr('src', data.image);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.title !== '' || data.description !== '' || data.image !== '') {
 | 
			
		||||
                    $this.removeClass('d-none');
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        $('.link-card').linkCard({
 | 
			
		||||
            endpoint: '{{ url('/api/checkin/card') }}'
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
@endpush
 | 
			
		||||
@@ -136,42 +136,8 @@
 | 
			
		||||
            form.submit();
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $('.link-card').each(function () {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: '{{ url('/api/checkin/card') }}',
 | 
			
		||||
                method: 'get',
 | 
			
		||||
                type: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    url: $this.find('a').attr('href')
 | 
			
		||||
                }
 | 
			
		||||
            }).then(function (data) {
 | 
			
		||||
                var $title = $this.find('.card-title');
 | 
			
		||||
                var $desc = $this.find('.card-text');
 | 
			
		||||
                var $image = $this.find('img');
 | 
			
		||||
 | 
			
		||||
                if (data.title === '') {
 | 
			
		||||
                    $title.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $title.text(data.title);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.description === '') {
 | 
			
		||||
                    $desc.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $desc.text(data.description);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.image === '') {
 | 
			
		||||
                    $image.hide();
 | 
			
		||||
                } else {
 | 
			
		||||
                    $image.attr('src', data.image);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (data.title !== '' || data.description !== '' || data.image !== '') {
 | 
			
		||||
                    $this.removeClass('d-none');
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        $('.link-card').linkCard({
 | 
			
		||||
            endpoint: '{{ url('/api/checkin/card') }}'
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
@endpush
 | 
			
		||||
		Reference in New Issue
	
	Block a user