よく使っているタグを表示する機能
This commit is contained in:
parent
bd93d9ec24
commit
9705c2ce5a
@ -39,7 +39,21 @@ SQL
|
||||
->with('tags')
|
||||
->paginate(20);
|
||||
|
||||
return view('user.profile')->with(compact('user', 'ejaculations'));
|
||||
// よく使っているタグ
|
||||
$tagsQuery = DB::table('ejaculations')
|
||||
->join('ejaculation_tag', 'ejaculations.id', '=', 'ejaculation_tag.ejaculation_id')
|
||||
->join('tags', 'ejaculation_tag.tag_id', '=', 'tags.id')
|
||||
->selectRaw('tags.name, count(*) as count')
|
||||
->where('ejaculations.user_id', $user->id);
|
||||
if (!Auth::check() || $user->id !== Auth::id()) {
|
||||
$tagsQuery = $tagsQuery->where('ejaculations.is_private', false);
|
||||
}
|
||||
$tags = $tagsQuery->groupBy('tags.name')
|
||||
->orderBy('count', 'desc')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
return view('user.profile')->with(compact('user', 'ejaculations', 'tags'));
|
||||
}
|
||||
|
||||
public function stats($name)
|
||||
|
@ -6,6 +6,8 @@
|
||||
<div class="col-lg-4">
|
||||
@component('components.profile', ['user' => $user])
|
||||
@endcomponent
|
||||
@section('sidebar')
|
||||
@show
|
||||
</div>
|
||||
<div class="col-lg-8">
|
||||
<ul class="nav nav-tabs">
|
||||
|
@ -1,5 +1,29 @@
|
||||
@extends('user.base')
|
||||
|
||||
@section('sidebar')
|
||||
{{-- TODO: タイムラインとオカズのテンプレを分けたら条件外す --}}
|
||||
@if (Route::currentRouteName() === 'user.profile')
|
||||
@if (!empty($tags) && (!$user->is_protected || $user->isMe()))
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
よく使っているタグ
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
@foreach ($tags as $tag)
|
||||
<a class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="oi oi-tag text-secondary"></span>
|
||||
{{ $tag->name }}
|
||||
</div>
|
||||
<span class="badge badge-secondary badge-pill">{{ $tag->count }}</span>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
@section('tab-content')
|
||||
@if ($user->is_protected && !$user->isMe())
|
||||
<p class="mt-4">
|
||||
|
Loading…
Reference in New Issue
Block a user