123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\allwin\model;
- use think\Model;
- class StoreUser extends Model{
- protected $pk = 'id';
- protected $table = 'ai_allwin_user';
-
- public function user(){
- return $this->hasOne('app\common\model\SystemUser','id','uid');
- }
-
- public function store(){
- return $this->hasOne('AllwinStore','id','store_id');
- }
-
- public function getUserStoreId(int $uid){
- return self::where(['uid' => $uid])->field('store_id')->find();
- }
-
- public static function editer(int $uid,int $store_id){
- $rel = self::where(['uid' => $uid])->find();
- if(empty($rel)){
- self::insert(['uid' => $uid,'store_id' => $store_id]);
- }else{
- $rel->uid = $uid;
- $rel->store_id = $store_id;
- $rel->save();
- }
- }
- }
|