<?php
declare(strict_types=1);

namespace app\common\model;

use app\common\model\base\BaseModel;

class Worker extends BaseModel
{

    //客户
    public function customer()
    {
        return $this->hasOne(Customer::class,'id','customer_id');
    }


    public function staff()
    {
        return $this->hasOne(User::class,'id','staff_id');
    }


    //获取店铺，规格id
    public static function getSpecsIdByShopId(string $shop_id): object
    {
        return self::where('shop_id', $shop_id)->findOrEmpty();
    }


    //获取店铺客户信息
    public static function getCustomerByShopId(int $shop_id): object
    {
        return self::alias('a')
            ->where('a.id', $shop_id)
            ->leftjoin('customer b', 'a.customer_id = b.id')
            ->field('b.id, b.account_term,b.cycle')
            ->find();
    }
}
