Apply.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model\supplier;
  3. use app\common\model\BaseModel;
  4. /**
  5. * 供应商申请模型
  6. */
  7. class Apply extends BaseModel
  8. {
  9. protected $pk = 'supplier_apply_id';
  10. protected $name = 'supplier_apply';
  11. /**
  12. * 关联营业执照照
  13. */
  14. public function businessImage()
  15. {
  16. return $this->hasOne('app\\common\\model\\file\\UploadFile', 'file_id', 'business_id');
  17. }
  18. /**
  19. * 关联会员记录表
  20. */
  21. public function user()
  22. {
  23. $module = self::getCalledModule() ?: 'common';
  24. return $this->belongsTo("app\\{$module}\\model\\user\\User");
  25. }
  26. /**
  27. * 关联分类表
  28. */
  29. public function category()
  30. {
  31. $module = self::getCalledModule() ?: 'common';
  32. return $this->hasOne("app\\{$module}\\model\\supplier\\Category",'category_id', 'category_id');
  33. }
  34. /**
  35. * 最近申请记录
  36. */
  37. public static function getLastDetail($user_id){
  38. return (new static())->where('user_id','=', $user_id)
  39. ->order('supplier_apply_id desc')
  40. ->find();
  41. }
  42. }