AuthorityService.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Services;
  3. use App\Authority;
  4. use App\Role;
  5. use Exception;
  6. use Illuminate\Support\Facades\Cache;
  7. class AuthorityService
  8. {
  9. // /**
  10. // * @return Authority[]
  11. // */
  12. // function getAll(){
  13. // $authorities = Cache::get('authorities');
  14. // if(!$authorities){
  15. // $authorities = Authority::with('roles')->get();
  16. // Cache::put('authorities', $authorities, config('cache.expirations.authorities'));
  17. // }
  18. // return $authorities;
  19. // }
  20. //
  21. // /**
  22. // * @param Authority $authority
  23. // * @return Role[]
  24. // * @throws Exception
  25. // */
  26. // function getRoles(Authority $authority){
  27. // if(!$authority['id']??'') throw new Exception('User对象或id不能为空');
  28. // $roles = Cache::get('authorityGetRoles'.$authority['id']);
  29. // if(!$roles){
  30. // $roles = Authority::with('roles')->get();
  31. // Cache::put('authorities', $roles, config('cache.expirations.authorities'));
  32. // }
  33. // return $roles;
  34. // }
  35. }