假如_丶

1920 经验值

https://packagist.org/packages/submitcheck 提示:

The vendor is already taken by someone else. You may ask them to add your package and give you maintainership access. If they add you as a maintainer on any package in that vendor namespace, you will then be able to add new packages in that namespace. The packages already in that vendor namespace can be found at laravel

这啥情况...

transform是否像Repositories似的想调用那个方法就用那个方法 - -,

比如说默认回到transform,在我定义其他的function,也是可以调用...

不是呀~,是每个transform文件只能有transform这一个方法嘛...

在输入错误的时候会把错误的值返回回来,但是数组怎么返回?

old('name') 

我是这样写的没有效果呀~old('tag_id[]')也没有...

 { Form::select('tag_id[]', $tags, old('tag_id'), ['class'=>'tag_id form-control','multiple'=>'multiple']) }
// AuthenticateTransformers
    public function transform(Customer $customer)
    {
        return [
            'id' => $customer['id'],
            'name' => $customer['name'],
            'username' => $customer['username'],
            'secret' => $customer['secret'],
            'startDate' => $customer['startDate'],
            'endDate' => $customer['endDate'],
            'token' => $customer['token'],
        ];
    }

    /**
     * @param \App\Models\Customer $customer
     *
     * @return array
     */
    public function getAuthenticatedUser(Customer $customer)
    {
        return [
            'id' => $customer['id'],
            'name' => $customer['name'],
            'username' => $customer['username'],
            'secret' => $customer['secret'],
            'startDate' => $customer['startDate'],
            'endDate' => $customer['endDate'],
        ];
    }

// 回调
return $this->item($customer, new AuthenticateTransformers, function ($resource, $fractal) {

            $fractal->setSerializer(new CustomSerializer());

});

查阅了一些文档,new Transformers的时候默认transform方法,
但是不能一个文件就为这一个方法而存吧,

我怎么在回调的时候想指向自定义的方法比如getAuthenticatedUser这个方法

我把GetUserFromTokenhandle修改了,但是提示token_invalid....

public function handle($request, \Closure $next)
    {
        $expired = false;
        $user = null;

        if (! $token = $this->auth->setRequest($request)->getToken()) {
            return $this->respond('tymon.jwt.absent', 'token_not_provided', 400);
        }

        try {
            $user = $this->auth->authenticate($token);
        } catch (TokenExpiredException $e) {
            // token 期满
            // return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]);
            $expired = true;
        } catch (JWTException $e) {
            // token 无效
            return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]);
        }

        if ($expired) {
            try {
                $newToken = $this->auth->setRequest($request)->parseToken()->refresh();
                $user = $this->auth->authenticate($newToken);
            } catch (TokenExpiredException $e) {
                return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]);
            } catch (JWTException $e) {
                return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]);
            }
            // send the refreshed token back to the client
            $request->headers->set('Authorization', 'Bearer '.$newToken);
        }

        if (! $user) {
            return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404);
        }
        $this->events->fire('tymon.jwt.valid', $user);

        return $next($request);
    }