1
0
Fork 0

Update FollowerController

This commit is contained in:
Daniel Supernault 2018-11-02 20:58:26 -06:00
parent 9154b3d630
commit bcd75c115c
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 17 additions and 4 deletions

View File

@ -2,12 +2,15 @@
namespace App\Http\Controllers;
use App\Follower;
use App\FollowRequest;
use App\Jobs\FollowPipeline\FollowPipeline;
use App\Profile;
use App\{
Follower,
FollowRequest,
Profile,
UserFilter
};
use Auth;
use Illuminate\Http\Request;
use App\Jobs\FollowPipeline\FollowPipeline;
class FollowerController extends Controller
{
@ -31,6 +34,16 @@ class FollowerController extends Controller
$user = Auth::user()->profile;
$target = Profile::where('id', '!=', $user->id)->findOrFail($item);
$private = (bool) $target->is_private;
$blocked = UserFilter::whereUserId($target->id)
->whereFilterType('block')
->whereFilterableId($user->id)
->whereFilterableType('App\Profile')
->exists();
if($blocked == true) {
return redirect()->back()->with('error', 'You cannot follow this user.');
}
$isFollowing = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->count();
if($private == true && $isFollowing == 0) {