BasicType.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\TopDepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class BasicType extends Model
  6. {
  7. protected $guarded = [];
  8. protected $table = "basic_type"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const type_22 = 22;
  13. public static $type = [
  14. 1 => '客户意向类型',
  15. 2 => '客户来源类型',
  16. 3 => '客户类型',
  17. 4 => '客户电话类型',
  18. 5 => '进展阶段类型',
  19. 6 => '客户状态类型',
  20. 7 => '决策关系类型',
  21. 8 => '客户分级',
  22. 9 => '状态类型',
  23. 10 => '车型',
  24. 11 => '订单类型',
  25. 12 => '成交类型',
  26. 13 => '合同状态',
  27. 14 => '合同类型',
  28. 15 => '付款方式',
  29. 16 => '发货状态',
  30. 17 => '物流公司',
  31. 18 => '安装方式',
  32. 19 => '紧急程度',
  33. 20 => '产品单位',
  34. 21 => '跟进方式',
  35. 22 => '产品价格'
  36. ];
  37. public static $user = [];
  38. public static $search = [];
  39. public static $is_search = false;
  40. public function __construct(array $attributes = [])
  41. {
  42. if(! empty($attributes['userData'])) {
  43. self::$user = $attributes['userData'];
  44. self::$search = $attributes['search'] ?? [];
  45. self::$is_search = true;
  46. }
  47. parent::__construct($attributes);
  48. }
  49. protected static function boot(){
  50. parent::boot();
  51. if(self::$is_search){
  52. static::addGlobalScope(new TopDepartmentScope(self::$user, self::$search));
  53. }
  54. }
  55. }