37
									
								
								app/Http/Controllers/TagController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/Http/Controllers/TagController.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Http\Controllers;
 | 
			
		||||
 | 
			
		||||
use App\Tag;
 | 
			
		||||
use Illuminate\Http\Request;
 | 
			
		||||
use Illuminate\Support\Facades\Auth;
 | 
			
		||||
use Illuminate\Support\Facades\DB;
 | 
			
		||||
 | 
			
		||||
class TagController extends Controller
 | 
			
		||||
{
 | 
			
		||||
    public function index()
 | 
			
		||||
    {
 | 
			
		||||
        $tags = Tag::select(DB::raw(
 | 
			
		||||
            <<<'SQL'
 | 
			
		||||
tags.name,
 | 
			
		||||
count(*) AS "checkins_count"
 | 
			
		||||
SQL
 | 
			
		||||
        ))
 | 
			
		||||
            ->join('ejaculation_tag', 'tags.id', '=', 'ejaculation_tag.tag_id')
 | 
			
		||||
            ->join('ejaculations', 'ejaculations.id', '=', 'ejaculation_tag.ejaculation_id')
 | 
			
		||||
            ->join('users', 'users.id', '=', 'ejaculations.user_id')
 | 
			
		||||
            ->where('ejaculations.is_private', false)
 | 
			
		||||
            ->where(function ($query) {
 | 
			
		||||
                $query->where('users.is_protected', false);
 | 
			
		||||
                if (Auth::check()) {
 | 
			
		||||
                    $query->orWhere('users.id', Auth::id());
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
            ->groupBy('tags.name')
 | 
			
		||||
            ->orderByDesc('checkins_count')
 | 
			
		||||
            ->orderBy('tags.name')
 | 
			
		||||
            ->paginate(100);
 | 
			
		||||
 | 
			
		||||
        return view('tag.index', compact('tags'));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								resources/assets/sass/app.scss
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								resources/assets/sass/app.scss
									
									
									
									
										vendored
									
									
								
							@@ -13,3 +13,6 @@ $primary: #e53fb1;
 | 
			
		||||
// Components
 | 
			
		||||
@import "components/ejaculation";
 | 
			
		||||
@import "components/link-card";
 | 
			
		||||
 | 
			
		||||
// Tag
 | 
			
		||||
@import "tag/index";
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								resources/assets/sass/tag/_index.scss
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/sass/tag/_index.scss
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
.tags {
 | 
			
		||||
  & > .btn-tag {
 | 
			
		||||
    width: 100%;
 | 
			
		||||
 | 
			
		||||
    .tag-name {
 | 
			
		||||
      display: inline-block;
 | 
			
		||||
      max-width: 80%;
 | 
			
		||||
      overflow: hidden;
 | 
			
		||||
      line-height: 40px;
 | 
			
		||||
      text-overflow: ellipsis;
 | 
			
		||||
      white-space: nowrap;
 | 
			
		||||
      vertical-align: middle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .checkins-count {
 | 
			
		||||
      display: inline-block;
 | 
			
		||||
      line-height: 40px;
 | 
			
		||||
      white-space: nowrap;
 | 
			
		||||
      vertical-align: middle;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -79,6 +79,9 @@
 | 
			
		||||
                        <li class="nav-item {{ stripos(Route::currentRouteName(), 'user.okazu') === 0 ? 'active' : ''}}">
 | 
			
		||||
                            <a class="nav-link" href="{{ route('user.okazu', ['name' => Auth::user()->name]) }}">オカズ</a>
 | 
			
		||||
                        </li>
 | 
			
		||||
                        <li class="nav-item {{ stripos(Route::currentRouteName(), 'tag') === 0 ? 'active' : ''}}">
 | 
			
		||||
                            <a class="nav-link" href="{{ route('tag') }}">タグ一覧</a>
 | 
			
		||||
                        </li>
 | 
			
		||||
                        {{--<li class="nav-item">
 | 
			
		||||
                            <a class="nav-link" href="{{ route('ranking') }}">ランキング</a>
 | 
			
		||||
                        </li>--}}
 | 
			
		||||
@@ -137,6 +140,13 @@
 | 
			
		||||
                            <a class="btn btn-{{ stripos(Route::currentRouteName(), 'user.okazu') === 0 ? 'primary' : 'outline-secondary'}}" href="{{ route('user.okazu', ['name' => Auth::user()->name]) }}" role="button">オカズ</a>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="row mt-2">
 | 
			
		||||
                        <div class="col">
 | 
			
		||||
                            <a class="btn btn-{{ stripos(Route::currentRouteName(), 'tag') === 0 ? 'primary' : 'outline-secondary'}}" href="{{ route('tag') }}" role="button">タグ一覧</a>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="col">
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    {{-- <div class="row mt-2">
 | 
			
		||||
                        <div class="col">
 | 
			
		||||
                            <a class="btn btn-outline-secondary" href="{{ route('ranking') }}">ランキング</a>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								resources/views/tag/index.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								resources/views/tag/index.blade.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
@extends('layouts.base')
 | 
			
		||||
 | 
			
		||||
@section('title', 'タグ一覧')
 | 
			
		||||
 | 
			
		||||
@section('content')
 | 
			
		||||
    <div class="container pb-1">
 | 
			
		||||
        <h2 class="mb-3">タグ一覧</h2>
 | 
			
		||||
        <p class="text-secondary">公開チェックインに付けられているタグを、チェックイン数の多い順で表示しています。</p>
 | 
			
		||||
        <div class="container-fluid">
 | 
			
		||||
            <div class="row mx-1">
 | 
			
		||||
                @foreach($tags as $tag)
 | 
			
		||||
                    <div class="col-12 col-lg-6 col-xl-3 py-3 text-break tags">
 | 
			
		||||
                        <a href="{{ route('search', ['q' => $tag->name]) }}" class="btn btn-outline-primary btn-tag" title="{{ $tag->name }}"><span class="tag-name">{{ $tag->name }}</span> <span class="checkins-count">({{ $tag->checkins_count }})</span></a>
 | 
			
		||||
                    </div>
 | 
			
		||||
                @endforeach
 | 
			
		||||
            </div>
 | 
			
		||||
            {{ $tags->links(null, ['className' => 'mt-4 justify-content-center']) }}
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
@endsection
 | 
			
		||||
@@ -46,6 +46,8 @@ Route::redirect('/search', '/search/checkin', 301);
 | 
			
		||||
Route::get('/search/checkin', 'SearchController@index')->name('search');
 | 
			
		||||
Route::get('/search/related-tag', 'SearchController@relatedTag')->name('search.related-tag');
 | 
			
		||||
 | 
			
		||||
Route::get('/tag', 'TagController@index')->name('tag');
 | 
			
		||||
 | 
			
		||||
Route::middleware('can:admin')
 | 
			
		||||
    ->namespace('Admin')
 | 
			
		||||
    ->prefix('admin')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user