A bare bones front-end for knockout designed for maximum compatibility with "obsolete" browsers
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

36 Zeilen
879B

  1. <?php
  2. namespace App\Knockout;
  3. use Illuminate\Support\Facades\Cache;
  4. class UserBan {
  5. private static function requestAll(int $userId): Dataset
  6. {
  7. $data = (new AbstractData)->httpGet(sprintf('/user/%u/bans', $userId));
  8. $json = json_decode($data);
  9. $records = array_map(function($user) {
  10. return Ban::unwrap($user);
  11. }, $json);
  12. return (new Dataset($records));
  13. }
  14. public static function updateAll(int $userId): Dataset
  15. {
  16. $key = sprintf('user-bans-%u', $userId);
  17. $data = self::requestAll($userId);
  18. Cache::put($key, $data, 300);
  19. return $data;
  20. }
  21. public static function all(int $userId): Dataset
  22. {
  23. $key = sprintf('user-bans-%u', $userId);
  24. return Cache::get($key, function() use($userId) {
  25. return self::updateAll($userId);
  26. });
  27. }
  28. }