123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- declare (strict_types = 1);
- namespace app\model;
- use app\account\model\AccountItem;use app\account\model\User;use think\Model;
- /**
- * @mixin \think\Model
- */
- class Account extends Model
- {
- public static $account_start=1;
- public static $account_end=0;
- public static $account_del=0;
- protected $globalScope=['Del'];
- protected $append=['depart_name','company_relaton'];
-
- public function scopeDel($query){
- $query->where('is_del',0);
- }
-
- public function getDepartNameAttr($v,$row){
- $item = new AccountItem();
- $depart=$item->where(['account_id'=>$row['id']])->with(['depart'])->findOrEmpty();
- return $depart->isEmpty()?'':$depart->depart_name;
- }
-
- public function getCompanyRelatonAttr($v,$row){
- $item = new AccountCompany();
- $company=$item->where(['account_id'=>$row['id'],'is_del' => 0, 'status' => 1])->column("companyCode,companyCode companyNo,companyName,companyName company_name,company_type,is_main,status");
- return $company;
- }
- public function UserInfo(){
- return $this->belongsTo(User::class,'id','account_id');
- }
-
- public function AccountItem(){
- return $this->belongsTo(AccountItem::class,'id','account_id');
- }
-
- public function CompanyRelat(){
-
- }
- }
|