Update DiscoverController
This commit is contained in:
parent
1a0661aec3
commit
328186d406
1 changed files with 34 additions and 7 deletions
|
@ -15,17 +15,44 @@ class DiscoverController extends Controller
|
||||||
|
|
||||||
public function home()
|
public function home()
|
||||||
{
|
{
|
||||||
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
|
$pid = Auth::user()->profile->id;
|
||||||
$people = Profile::inRandomOrder()->where('id', '!=', Auth::user()->profile->id)->whereNotIn('id', $following)->take(3)->get();
|
|
||||||
$posts = Status::whereHas('media')->where('profile_id', '!=', Auth::user()->profile->id)->whereNotIn('profile_id', $following)->orderBy('created_at', 'desc')->take('21')->get();
|
$following = Follower::whereProfileId($pid)
|
||||||
|
->pluck('following_id');
|
||||||
|
|
||||||
|
$people = Profile::inRandomOrder()
|
||||||
|
->where('id', '!=', $pid)
|
||||||
|
->whereNotIn('id', $following)
|
||||||
|
->take(3)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$posts = Status::whereHas('media')
|
||||||
|
->where('profile_id', '!=', $pid)
|
||||||
|
->whereNotIn('profile_id', $following)
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->simplePaginate(21);
|
||||||
|
|
||||||
return view('discover.home', compact('people', 'posts'));
|
return view('discover.home', compact('people', 'posts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showTags(Request $request, $hashtag)
|
public function showTags(Request $request, $hashtag)
|
||||||
{
|
{
|
||||||
$tag = Hashtag::whereSlug($hashtag)->firstOrFail();
|
$this->validate($request, [
|
||||||
$posts = $tag->posts()->has('media')->orderBy('id','desc')->paginate(12);
|
'page' => 'nullable|integer|min:1|max:10'
|
||||||
$count = $tag->posts()->has('media')->orderBy('id','desc')->count();
|
]);
|
||||||
return view('discover.tags.show', compact('tag', 'posts', 'count'));
|
|
||||||
|
$tag = Hashtag::with('posts')
|
||||||
|
->withCount('posts')
|
||||||
|
->whereSlug($hashtag)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$posts = $tag->posts()
|
||||||
|
->whereIsNsfw(false)
|
||||||
|
->whereVisibility('public')
|
||||||
|
->has('media')
|
||||||
|
->orderBy('id','desc')
|
||||||
|
->simplePaginate(12);
|
||||||
|
|
||||||
|
return view('discover.tags.show', compact('tag', 'posts'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue