チェックイン非公開ユーザーのチェックインが検索結果として表示される問題の修正

This commit is contained in:
shibafu 2019-04-07 00:10:01 +09:00
parent 212fad4d66
commit 9cec184d21

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'])