| Total Complexity | 3 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | trait CacheableAll |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Retrieve a Collection of all instances of this model. |
||
| 14 | * |
||
| 15 | * @param array $columns |
||
| 16 | * @return Collection|mixed |
||
| 17 | */ |
||
| 18 | public static function all($columns = ['*']) |
||
| 19 | { |
||
| 20 | // todo: fix use of serializeHash() function |
||
| 21 | return Cache::rememberForever(parent::getTableName().':all#'.LaravelHelpers::serializeHash($columns), |
||
| 22 | function () use ($columns) { |
||
| 23 | return parent::all($columns); |
||
| 24 | } |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Invalidate a Model's cache. |
||
| 30 | * |
||
| 31 | * @param string|null $key |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | public static function invalidateCache(string $key = null) |
||
| 37 | } |
||
| 38 | } |
||
| 39 |