Supplier.php 655 B

123456789101112131415161718192021
  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){
  16. if(!$is_all) return $query->where('status',1)->where('is_deleted',0);
  17. })->column('id,title,is_deleted,status','id');
  18. }
  19. }