gg444108853

478 经验值

  • 恩 好的

  • 另外问一下你这个怎么解决防盗链问题的 后面参数是怎么获取到的?

        'qiniu' => [
            'driver' => 'qiniu',
            'domains' => [
                'default' => 'xxxxx.com1.z0.glb.clouddn.com', //你的七牛域名
                'https' => 'dn-yourdomain.qbox.me',         //你的HTTPS域名
                'custom' => 'static.abc.com',                //你的自定义域名
            ],
            'access_key' => '',  //AccessKey
            'secret_key' => '',  //SecretKey
            'bucket' => '',  //Bucket名字
            'notify_url' => '',  //持久化处理回调地址
        ],

这个配置会不会和你的配置冲突 这是laravel七牛插件

这两个七牛的话 要是用肯定要用超哥的了....

那个自定义验证码格式,怎么获取状态码?

public function getAuthenticatedUser()
{
    try {

        if (! $user = JWTAuth::parseToken()->authenticate()) {
            return response()->json(['user_not_found'], 404);
        }

    } catch (TokenExpiredException $e) {

        return response()->json(['token_expired'], $e->getStatusCode());

    } catch (TokenInvalidException $e) {

        return response()->json(['token_invalid'], $e->getStatusCode());

    } catch (JWTException $e) {

        return response()->json(['token_absent'], $e->getStatusCode());

    }
    // the token is valid and we have found the user via the sub claim
    return $this->response->collection($user, new UserTransformer, [], function ($resource, $fractal) {
        $fractal->setSerializer(new CustomSerializer);
    });
    //return response()->json(compact('user'));
}

就是获取user信息那个函数,然后就是提示$fractal那行有错误

public function index()
{
    $data = User::all();
    //return $this->response->collection($data4,new LessonTransformer());
    return $this->response->collection($data, new UserTransformer(), [], function ($resource, $fractal) {
        $fractal->setSerializer(new CustomSerializer);
    });
}
public function getAuthenticatedUser()
{
    try {

        if (! $user = JWTAuth::parseToken()->authenticate()) {
            return response()->json(['user_not_found'], 404);
        }

    } catch (TokenExpiredException $e) {

        return response()->json(['token_expired'], $e->getStatusCode());

    } catch (TokenInvalidException $e) {

        return response()->json(['token_invalid'], $e->getStatusCode());

    } catch (JWTException $e) {

        return response()->json(['token_absent'], $e->getStatusCode());

    }
    // the token is valid and we have found the user via the sub claim
    return $this->response->collection($user, new UserTransformer, [], function ($resource, $fractal) {
        $fractal->setSerializer(new CustomSerializer);

    });
    //return response()->json(compact('user'));
}
{
  "message": "Argument 1 passed to Dingo\\Api\\Http\\Response\\Factory::collection() must be an instance of Illuminate\\Support\\Collection, instance of App\\User given, called in /var/www/html/api/app/Api/Controllers/AuthController.php on line 104 and defined",
  "status_code": 500
}