Update DiscoverController

This commit is contained in:
Daniel Supernault 2018-05-29 21:04:26 -06:00
parent e37108c544
commit 672ec191c6

View file

@ -3,13 +3,22 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\{Hashtag, Status, StatusHashtag};
use App\{Hashtag, Follower, Profile, Status, StatusHashtag};
use Auth;
class DiscoverController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function home()
{
return view('discover.home');
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
$people = Profile::whereNotIn('id', $following)->orderByRaw('rand()')->take(3)->get();
$posts = Status::whereHas('media')->whereNotIn('profile_id', $following)->orderBy('created_at', 'desc')->take('21')->get();
return view('discover.home', compact('people', 'posts'));
}
public function showTags(Request $request, $hashtag)