Supplier.php 611 B

12345678910111213141516171819
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. // 供应商
  5. class Supplier extends Model
  6. {
  7. public function goodsList(){
  8. return $this->hasMany('SupplierGoods','supplier_id')
  9. ->where('is_deleted',0)->where('release_time','< time',date("Y-m-d H:i:s"))
  10. ->field('id,supplier_id,name,cover,read_num,create_at');
  11. }
  12. // 获取供应商名称
  13. public static function getSupplierName($is_all = 0)
  14. {
  15. return self::when($is_all,function ($query)use ($is_all){if(!$is_all)return $query->where('status',1)->where('is_deleted',0);})->column('title','id');
  16. }
  17. }