<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Product\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\ArrayUtil; use ModStart\Core\Util\HtmlUtil; class ProductUtil { public static function buildRecord($Lu5WV) { goto eoYbv; eoYbv: $qgfZ7 = ArrayUtil::keepKeys($Lu5WV, array('id', 'cover', 'title', 'updated_at')); goto SvVyi; qRP02: return $qgfZ7; goto Prs3u; SvVyi: $qgfZ7['day'] = date('Y-m-d', strtotime($Lu5WV['created_at'])); goto UWdxe; UWdxe: if (empty($Lu5WV['cover'])) { $k1_u1 = HtmlUtil::extractTextAndImages($Lu5WV['content']); if (!empty($k1_u1['images'])) { $qgfZ7['cover'] = $k1_u1['images'][0]; } } goto qRP02; Prs3u: } public static function buildRecords($vKRZ2) { foreach ($vKRZ2 as $l0ek5 => $Lu5WV) { $vKRZ2[$l0ek5] = self::buildRecord($Lu5WV); } return $vKRZ2; } public static function listLatest($BMu21 = 5) { $vKRZ2 = ModelUtil::model('product')->orderBy('id', 'desc')->limit($BMu21)->get()->toArray(); return self::buildRecords($vKRZ2); } public static function get($WXJys) { return ModelUtil::get('product', array('id' => $WXJys)); } public static function listCategories() { return ModelUtil::model('product_category')->orderBy('sort', 'asc')->get()->toArray(); } }