2018-04-15 19:56:17 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2018-05-31 16:05:39 -06:00
|
|
|
use Auth;
|
|
|
|
use App\{Follower, Status, User};
|
2018-04-15 19:56:17 -06:00
|
|
|
|
|
|
|
class TimelineController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function personal()
|
|
|
|
{
|
2018-05-31 16:05:39 -06:00
|
|
|
// TODO: Use redis for timelines
|
|
|
|
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
|
2018-06-03 21:38:29 -06:00
|
|
|
$following->push(Auth::user()->profile->id);
|
2018-06-03 19:40:19 -06:00
|
|
|
$timeline = Status::whereHas('media')
|
|
|
|
->whereNull('in_reply_to_id')
|
|
|
|
->whereIn('profile_id', $following)
|
|
|
|
->orderBy('id','desc')
|
|
|
|
->withCount(['comments', 'likes'])
|
|
|
|
->simplePaginate(10);
|
2018-04-18 23:56:59 -06:00
|
|
|
return view('timeline.personal', compact('timeline'));
|
2018-04-15 19:56:17 -06:00
|
|
|
}
|
2018-05-31 16:05:39 -06:00
|
|
|
|
|
|
|
public function local()
|
|
|
|
{
|
|
|
|
// TODO: Use redis for timelines
|
2018-06-03 19:40:19 -06:00
|
|
|
$timeline = Status::whereHas('media')
|
|
|
|
->whereNull('in_reply_to_id')
|
|
|
|
->orderBy('id','desc')
|
|
|
|
->withCount(['comments', 'likes'])
|
|
|
|
->simplePaginate(10);
|
2018-05-31 16:05:39 -06:00
|
|
|
return view('timeline.public', compact('timeline'));
|
|
|
|
}
|
|
|
|
|
2018-04-15 19:56:17 -06:00
|
|
|
}
|