InfyOm\Generator\Utils\ResponseUtil::makeError PHP Method

makeError() public static method

public static makeError ( string $message, array $data = [] ) : array
$message string
$data array
return array
    public static function makeError($message, array $data = [])
    {
        $res = ['success' => false, 'message' => $message];
        if (!empty($data)) {
            $res['data'] = $data;
        }
        return $res;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param int $id
  * @return Response
  *
  * @SWG\Delete(
  *      path="/ajudas/{id}",
  *      summary="Remove the specified Ajuda from storage",
  *      tags={"Ajuda"},
  *      description="Delete Ajuda",
  *      produces={"application/json"},
  *      @SWG\Parameter(
  *          name="id",
  *          description="id of Ajuda",
  *          type="integer",
  *          required=true,
  *          in="path"
  *      ),
  *      @SWG\Response(
  *          response=200,
  *          description="successful operation",
  *          @SWG\Schema(
  *              type="object",
  *              @SWG\Property(
  *                  property="success",
  *                  type="boolean"
  *              ),
  *              @SWG\Property(
  *                  property="data",
  *                  type="string"
  *              ),
  *              @SWG\Property(
  *                  property="message",
  *                  type="string"
  *              )
  *          )
  *      )
  * )
  */
 public function destroy($id)
 {
     /** @var Ajuda $ajuda */
     $ajuda = $this->ajudaRepository->find($id);
     if (empty($ajuda)) {
         return Response::json(ResponseUtil::makeError('Ajuda not found'), 404);
     }
     $ajuda->delete();
     return $this->sendResponse($id, 'Ajuda deleted successfully');
 }
All Usage Examples Of InfyOm\Generator\Utils\ResponseUtil::makeError