初始化仓库
This commit is contained in:
38
common/models/StoreUser.php
Normal file
38
common/models/StoreUser.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
class StoreUser extends \common\modelsgii\StoreUser
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class'=>TimestampBehavior::class,
|
||||
'attributes'=>[
|
||||
ActiveRecord::EVENT_BEFORE_INSERT=>['created_at','updated_at'],
|
||||
ActiveRecord::EVENT_BEFORE_UPDATE=>['updated_at'],
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
//关联用户端用户
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::class,['id'=>'user_id']);
|
||||
}
|
||||
|
||||
//关联门店
|
||||
public function getStore()
|
||||
{
|
||||
return $this->hasOne(Store::class,['id'=>'store_id']);
|
||||
}
|
||||
|
||||
public function getNav(){
|
||||
return $this->hasMany(Nav::class,['store_id'=>'store_id'])->andWhere(['id_delete' => 0])->orderBy('sort ASC,id ASC');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user