A bare bones front-end for knockout designed for maximum compatibility with "obsolete" browsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
803B

  1. <?php
  2. namespace App\Knockout;
  3. use Illuminate\Support\Facades\Cache;
  4. class Subforum {
  5. private static function unwrap($subforum)
  6. {
  7. $s = new self();
  8. $s->id = $subforum->id;
  9. $s->name = $subforum->name;
  10. $s->description = $subforum->description;
  11. return $s;
  12. }
  13. public static function getAll()
  14. {
  15. $data = (new AbstractData)->httpGet('/subforum');
  16. $json = json_decode($data);
  17. return array_map(function($subforum) {
  18. return self::unwrap($subforum);
  19. }, $json->list);
  20. }
  21. public static function updateCache()
  22. {
  23. Cache::forever('subforums', self::getAll());
  24. }
  25. public static function getCache()
  26. {
  27. return Cache::get('subforums', []);
  28. }
  29. }