SalesOrder.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class SalesOrder extends Model
  6. {
  7. protected $fillable = ['userData'];
  8. protected $table = "sales_order"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const Model_type_one = 1; // 线下订单合同
  13. const Model_type_two = 2; // 分社订货合同
  14. const Model_type_three = 3; // 二手车精品加装合同
  15. public static $model_type = [
  16. self::Model_type_one,
  17. self::Model_type_two,
  18. self::Model_type_three
  19. ];
  20. public static $prefix = [
  21. self::Model_type_one => 'T9XS.',
  22. self::Model_type_two => 'T9SO.',
  23. self::Model_type_three => 'T9XS.'
  24. ];
  25. public static $user = [];
  26. public static $is_search = false;
  27. public function __construct(array $attributes = [])
  28. {
  29. if(! empty($attributes['userData'])) {
  30. self::$user = $attributes['userData'];
  31. self::$is_search = true;
  32. }
  33. parent::__construct($attributes);
  34. }
  35. protected static function boot(){
  36. parent::boot();
  37. if(self::$is_search){
  38. static::addGlobalScope(new DepartmentScope(self::$user));
  39. }
  40. }
  41. }