CacheEnum.php 696 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace App\Repositories\Enums;
  11. use Illuminate\Support\Carbon;
  12. use Jiannei\Enum\Laravel\Repositories\Enums\CacheEnum as BaseCacheEnum;
  13. class CacheEnum extends BaseCacheEnum
  14. {
  15. const AUTHORIZATION_USER = 'authorizationUser';
  16. protected static function authorizationUser($options)
  17. {
  18. $exp = auth('api')->payload()->get('exp'); // token 剩余有效时间
  19. return Carbon::now()->diffInSeconds(Carbon::createFromTimestamp($exp));
  20. }
  21. }