<?php
 namespace Module\CmsProperty\Web\Controller; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\PageHtmlUtil; use ModStart\Module\ModuleBaseController; use ModStart\Module\ModuleManager; use Module\Ad\Util\AdUtil; use Module\CmsProperty\Util\CmsPropertyUtil; class CmsPropertyController extends ModuleBaseController { private $api; public function __construct() { $this->api = app(\Module\CmsProperty\Api\Controller\CmsPropertyController::class); } public function index() { $input = InputPackage::buildFromInput(); $paginateData = Response::tryGetData($this->api->paginate()); $dataView = []; $dataView['records'] = $paginateData['records']; $dataView['categoryId'] = $input->getInteger('categoryId'); $dataView['categories'] = CmsPropertyUtil::listCategories(); $dataView['pageHtml'] = PageHtmlUtil::render($paginateData['total'], $paginateData['pageSize'], $paginateData['page'], '?' . Request::mergeQueries(['page' => ['{page}']])); return $this->view('cmsProperty.list', $dataView); } public function views($id) { $record = CmsPropertyUtil::get($id); if (empty($record)) { return Response::send(-1, '新闻不存在'); } $record['_category'] = ModelUtil::get('cms_property_category', ['id' => $record['categoryId']]); $dataView = []; $dataView['record'] = $record; return $this->view('cmsProperty.view', $dataView); } }