public function followUser($user, $to_follow_uuid) { if ($this->getUserFollowstatus($user, $to_follow_uuid) == 0) { $uf = new Users_follow(); $uf->uuid = $user; $uf->follow_type = 2; $uf->obj_id = $to_follow_uuid; $uf->save(); $notification = new Notification(); $notification->store(2, $to_follow_uuid, $user, 'follow'); event(new \App\Events\FollowUserEvent($user, $to_follow_uuid)); return 1; } else { DB::table('users_follow')->where('uuid', $user)->where('obj_id', $to_follow_uuid)->delete(); DB::table('notification')->where('recipient', $to_follow_uuid)->where('sender', $user)->delete(); return 0; } }