Ejemplo n.º 1
0
 public function followerMustBeUnique(FunctionalTester $I)
 {
     $rel = Follower::findFirst();
     $this->model->user_id = $rel->user_id;
     $this->model->follower_id = $rel->follower_id;
     $I->assertFalse($this->model->save());
 }
 /**
  *  @SWG\Delete(
  *      path="/followers/{id}",
  *      tags={"follower"},
  *      summary="Deletes an follower relationship",
  *      description="Deletes an follower relationship given the follower_id.",
  *      operationId="deleteFollowers",
  *      @SWG\Parameter(
  *          name="id",
  *          in="path",
  *          description="User ID whom follower is going to be deleted",
  *          required=true,
  *          type="integer",
  *      ),
  *      @SWG\Parameter(
  *          in="formData",
  *          name="follower_id",
  *          description="Follower id",
  *          required=true,
  *          type="integer",
  *      ),
  *      @SWG\Response(
  *          response=200,
  *          description="Successfully deleted",
  *          @SWG\Schema(ref="#/definitions/SuccessResponse"),
  *          examples={
  *              "application/json": {
  *                  "status"="OK"
  *              }
  *          },
  *      ),
  *      @SWG\Response(
  *          response="401",
  *          description="Not authorized",
  *          @SWG\Schema(ref="#/definitions/ErrorResponse"),
  *      ),
  *  )
  */
 public function delete($id)
 {
     $id = $this->filter->sanitize($id, 'int');
     try {
         $user = User::findFirstOrFail(['id = ?0', 'bind' => [$id]]);
         $follower = User::findFirstOrFail(['id = ?0', 'bind' => [$this->request->get('follower_id', 'int')]], 'Follower User');
         $relationship = Follower::findFirstOrFail(['user_id' => $user->id, 'follower_id' => $follower->id]);
         return $this->response($relationship);
     } catch (ResourceNotFoundException $e) {
         return $e->returnResponse();
     }
 }