/** * @param $user * @return string */ public function apiToken($user) { $token = \Laravel\Spark\Token::create(['id' => Uuid::uuid4(), 'user_id' => $user->id, 'name' => 'test_token', 'token' => str_random(60), 'metadata' => '[]']); return 'api_token=' . $token->token; }
/** * Determine if the current API token is granted a given ability. * * @param string $ability * @return bool */ public function tokenCan($ability) { return $this->currentToken ? $this->currentToken->can($ability) : false; }
/** * {@inheritdoc} */ public function updateToken(Token $token, $name, array $abilities = []) { $metadata = $token->metadata; $metadata['abilities'] = $abilities; $token->forceFill(['name' => $name, 'metadata' => $metadata])->save(); }