芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/models/BaseModel.php
<?php namespace app\models; use Yii; use yii\db\ActiveRecord; use app\components\BaseActiveQuery; use yii\base\Exception; class BaseModel extends ActiveRecord{ // var $branch_id; public function init(){ parent::init(); if($this->hasAttribute('branch_id') && get_class($this)!='app\models\User'){ $this->branch_id=Yii::$app->params['branch_id']; } } public static function find() { $active_query=new BaseActiveQuery(get_called_class()); return $active_query; } public function beforeSave($insert) { if (!parent::beforeSave($insert)) { return false; } if($this->hasAttribute('branch_id') && get_class($this)!='app\models\User'){ $this->branch_id=Yii::$app->params['branch_id']; } return true; } }