芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/controllers/CustomerController.php
<?php namespace app\controllers; use yii; use yii\rest\ActiveController; use app\models\Customer; use app\models\License; use app\models\Payment; use app\components\StringHelper; use app\models\CustomerLicense; use yii\base\DynamicModel; class CustomerController extends ActiveController{ public $modelClass='app\models\Customer'; public function actions(){ $actions=parent::actions(); $actions['index']['dataFilter']=[ 'class'=>'yii\data\ActiveDataFilter', 'searchModel'=>(new DynamicModel(['name']))->addRule(['name'],'string') ]; return $actions; } public function serializeData($data){ $result=parent::serializeData($data); if($this->action->id=='view'){ $catalogs=$this->getCatalogs(); $result['licenses']=$catalogs['licenses']; } return $result; } private function getCatalogs(){ $licenses=License::find()->where(['active'=>1,'trash'=>0])->all(); return ['licenses'=>$licenses]; } public function actionCatalogs(){ return $this->getCatalogs(); } } ?>