Customer.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Customer extends Model
  6. {
  7. // protected $fillable = ['userData','search'];
  8. protected $guarded = [];
  9. protected $table = "customer"; //指定表
  10. const CREATED_AT = 'crt_time';
  11. const UPDATED_AT = 'upd_time';
  12. protected $dateFormat = 'U';
  13. const Model_type_one = 1; // 基础模板
  14. const Model_type_two = 2; // T9二手车客户模板
  15. public static $model_type = [
  16. self::Model_type_one,
  17. self::Model_type_two
  18. ];
  19. public static $user = [];
  20. public static $search = [];
  21. public static $limitKey = "customerPondState";
  22. const range_function = 'customerRange';
  23. public function __construct(array $attributes = [])
  24. {
  25. if(! empty($attributes['userData'])) {
  26. self::$user = $attributes['userData'];
  27. self::$search = $attributes['search'];
  28. self::$user['range_function'] = self::range_function;
  29. //进入公海池 去掉限制
  30. if(! empty(self::$search['pond_state'])) static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  31. }
  32. parent::__construct($attributes);
  33. }
  34. }