<?php
 namespace Module\CmsJob\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\ArrayUtil; class CmsJobUtil { public static function buildRecord($record) { $item = ArrayUtil::keepKeys($record, ['id', 'title', 'updated_at',]); $item['day'] = date('Y-m-d', strtotime($record['created_at'])); return $item; } public static function buildRecords($records) { foreach ($records as $k => $record) { $records[$k] = self::buildRecord($record); } return $records; } public static function listLatest($limit = 5) { $records = ModelUtil::model('cms_job') ->orderBy('id', 'desc') ->limit($limit)->get()->toArray(); return self::buildRecords($records); } public static function get($id) { return ModelUtil::get('cms_job', ['id' => $id]); } }