(Update) FollowController

Check if user notify should happen based on permissions.
This commit is contained in:
singularity43
2019-01-30 21:39:01 -05:00
parent ab14bc0b09
commit 7fdfbca5b0
+6 -6
View File
@@ -53,9 +53,9 @@ class FollowController extends Controller
$follow->user_id = auth()->user()->id;
$follow->target_id = $user->id;
$follow->save();
$user->notify(new NewFollow('user', auth()->user()->username, $follow));
if ($user->acceptsNotification(auth()->user(),$user,'account','show_account_follow')) {
$user->notify(new NewFollow('user', auth()->user(), $user, $follow));
}
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
->with($this->toastr->success('You are now following '.$user->username, 'Yay!', ['options']));
} else {
@@ -76,9 +76,9 @@ class FollowController extends Controller
if (auth()->user()->isFollowing($user->id)) {
$follow = auth()->user()->follows()->where('target_id', '=', $user->id)->first();
$follow->delete();
$user->notify(new NewUnfollow('user', auth()->user()->username, auth()->user()->id));
if ($user->acceptsNotification(auth()->user(),$user,'account','show_account_unfollow')) {
$user->notify(new NewUnfollow('user', auth()->user(), $user, $follow));
}
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
->with($this->toastr->success('You are no longer following '.$user->username, 'Yay!', ['options']));
} else {