ReturnExchangeOrder.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ReturnExchangeOrder extends Model
  6. {
  7. // protected $fillable = ['userData'];
  8. protected $guarded = [];
  9. protected $table = "return_exchange_order"; //指定表
  10. const CREATED_AT = 'crt_time';
  11. const UPDATED_AT = 'upd_time';
  12. protected $dateFormat = 'U';
  13. const Order_type = 0; //合同
  14. const Order_type2 = 1; // 采购单
  15. public static $order_type_name = [
  16. self::Order_type => '合同',
  17. self::Order_type2 => '采购单',
  18. ];
  19. const Model_type_one = 1; // 退货单
  20. const Model_type_two = 2; // 换货单
  21. public static $model_type = [
  22. self::Model_type_one,
  23. self::Model_type_two,
  24. ];
  25. public static $model_type_name = [
  26. self::Model_type_one => '退货单',
  27. self::Model_type_two => '换货单',
  28. ];
  29. const State_zero = 0;//未确认
  30. const State_one = 1;//已确认
  31. public static $state = [
  32. self::State_zero => '未确认',
  33. self::State_one => '已确认',
  34. ];
  35. public static $prefix = [
  36. self::Model_type_one => 'TH',
  37. self::Model_type_two => 'HH',
  38. ];
  39. public static $user = [];
  40. public static $search = [];
  41. const range_function = 'returnExchangeOrderRange';
  42. public function __construct(array $attributes = [])
  43. {
  44. if(! empty($attributes['userData'])) {
  45. self::$user = $attributes['userData'];
  46. self::$user['range_function'] = self::range_function;
  47. self::$search = $attributes['search'];
  48. static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  49. }
  50. parent::__construct($attributes);
  51. }
  52. }