service层有一些通用方法,例如GetModelName 有的没有。该方法在自己需要编写RestFul接口时要用到。建议将该方法写在Service类下,或者使用trait引入。
/**
* 得到category model的全名.
*/
protected function actionGetModelName()
{
return get_class($this->_article->getByPrimaryKey());
}
namespace appserver\local\local_modules\mysqldb\customer;
use yii\behaviors\TimestampBehavior;
class Address extends \fecshop\models\mysqldb\customer\Address{
public function behaviors()
{
return [
[
'class'=>TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => time()
]
];
}
}
好的 附上代码