<?php
 namespace Module\Document\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; class DocumentUtil { const CACHE_KEY_PREFIX = 'document:'; public static function add($title, $content) { return ModelUtil::insert('document', [ 'title' => $title, 'content' => $content ]); } public static function get($id) { return ModelUtil::get('document', $id); } public static function lists() { return ModelUtil::model('document')->orderBy('sort', 'asc')->get()->toArray(); } public static function listWithCache($minutes = 60) { return Cache::remember(self::CACHE_KEY_PREFIX . 'list', $minutes, function () { return self::lists(); }); } public static function clearCache() { Cache::forget(self::CACHE_KEY_PREFIX . 'list'); } }