public function remove(Request $request, Application $app, $user_id, $friend_id) { $model = new Friend($app['neo']); if ($model->delete($user_id, $friend_id)) { return $this->sendJson(['success' => true], 200); } else { return $this->sendJson(['seccess' => false], 404); } }
public function accept(Request $request, Application $app, $user_id, $request_id) { $result = false; $requestModel = new FriendshipRequest($app['neo']); //Get friendship request data by request id $requestData = $requestModel->getById($user_id, $request_id); if ($requestData && isset($requestData['to']) && $user_id == $requestData['to']) { $friendModel = new Friend($app['neo']); //Trying to create bidirectional friendship relation if ($friendModel->create($user_id, $requestData['from'])) { //Remove friendship request $requestModel->delete($request_id); $result = true; } } if ($result) { return $this->sendJson(['success' => true], 200); } else { return $this->sendJson(['success' => false], 404); } }