<?php

namespace App\libs\helpers;

class Response
{
    /**
     * 成功返回.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function success($data = '', $message = 'Success')
    {
        return response()->json(['code' => 0, 'message' => $message, 'data' => $data]);
    }

    /**
     * 失败返回.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function fail($message = 'Fail')
    {
        return response()->json(['code' => 1, 'message' => $message, 'data' => '']);
    }

    /**
     * 自定义返回.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function defined($code, $message, $data = '')
    {
        return response()->json(['code' => $code, 'message' => $message, 'data' => $data]);
    }

    /**
     * 鉴权未登录.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function unLogin()
    {
        return response()->json(['code' => 1001, 'message' => '请先登录，再进行操作', 'data' => '']);
    }
}
