UserObserver.php 653 B

1234567891011121314151617181920212223242526272829
  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\Observers;
  11. use App\Repositories\Enums\CacheEnum;
  12. use App\Repositories\Models\User;
  13. use Illuminate\Support\Facades\Cache;
  14. class UserObserver
  15. {
  16. public function updated(User $user)
  17. {
  18. Cache::forget(CacheEnum::getCacheKey(CacheEnum::AUTHORIZATION_USER));
  19. }
  20. public function deleted(User $user)
  21. {
  22. Cache::forget(CacheEnum::getCacheKey(CacheEnum::AUTHORIZATION_USER));
  23. }
  24. }