<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Photo\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\ArrayUtil; use ModStart\Core\Util\TimeUtil; class PhotoUtil { const PREFIX = 'Photo:'; public static function clearCache() { for ($QhDyd = 0; $QhDyd < 20; $QhDyd++) { Cache::forget(self::PREFIX . "Latest:{$QhDyd}"); } Cache::forget(self::PREFIX . 'All'); } public static function listLatest($BZCSp = 5) { return Cache::remember(self::PREFIX . 'Latest:' . $BZCSp, TimeUtil::MINUTE_PERIOD_DAY, function () use($BZCSp) { $Ge6HJ = ModelUtil::model('photo')->orderBy('id', 'desc')->limit($BZCSp)->get(array('id', 'title', 'summary', 'cover'))->toArray(); return self::buildRecords($Ge6HJ); }); } public static function get($DcXJr) { return ModelUtil::get('photo', array('id' => $DcXJr)); } public static function buildRecord($HuYBt) { $zEBpl = ArrayUtil::keepKeys($HuYBt, array('id', 'title', 'updated_at', 'thumb', 'url', 'height', 'width')); return $zEBpl; } public static function buildRecords($Ge6HJ) { foreach ($Ge6HJ as $d2HEV => $HuYBt) { $Ge6HJ[$d2HEV] = self::buildRecord($HuYBt); } return $Ge6HJ; } }