ReturnExchangeOrder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. public static $is_search = false;
  42. const range_function = 'returnExchangeOrderRange';
  43. public function __construct(array $attributes = [])
  44. {
  45. if(! empty($attributes['userData'])) {
  46. self::$user = $attributes['userData'];
  47. self::$user['range_function'] = self::range_function;
  48. self::$search = $attributes['search'];
  49. self::$is_search = true;
  50. }
  51. parent::__construct($attributes);
  52. }
  53. protected static function boot(){
  54. parent::boot();
  55. if(self::$is_search){
  56. static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  57. }
  58. }
  59. }