|
- <?php
-
- namespace App\Knockout;
-
- use Illuminate\Support\Facades\Cache;
-
- class Subforum {
-
- private static function unwrap($subforum)
- {
- $s = new self();
-
- $s->id = $subforum->id;
- $s->name = $subforum->name;
- $s->description = $subforum->description;
-
- return $s;
- }
-
- public static function getAll()
- {
- $data = (new AbstractData)->httpGet('/subforum');
- $json = json_decode($data);
- return array_map(function($subforum) {
- return self::unwrap($subforum);
- }, $json->list);
- }
-
- public static function updateCache()
- {
- Cache::forever('subforums', self::getAll());
- }
-
- public static function getCache()
- {
- return Cache::get('subforums', []);
- }
-
- }
|