Merge pull request #170 from shikorism/fix/visibility-issue-on-search

チェックイン非公開ユーザーのチェックインが検索結果として表示される問題の修正
This commit is contained in:
shibafu 2019-04-07 00:13:16 +09:00 committed by GitHub
commit 3cba46bff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Ejaculation; use App\Ejaculation;
use App\Tag; use App\Tag;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class SearchController extends Controller class SearchController extends Controller
{ {
@ -18,6 +19,12 @@ class SearchController extends Controller
->whereHas('tags', function ($query) use ($inputs) { ->whereHas('tags', function ($query) use ($inputs) {
$query->where('name', 'like', "%{$inputs['q']}%"); $query->where('name', 'like', "%{$inputs['q']}%");
}) })
->whereHas('user', function ($query) {
$query->where('is_protected', false);
if (Auth::check()) {
$query->orWhere('id', Auth::id());
}
})
->where('is_private', false) ->where('is_private', false)
->orderBy('ejaculated_date', 'desc') ->orderBy('ejaculated_date', 'desc')
->with(['user', 'tags']) ->with(['user', 'tags'])