ReturnExchangeOrder.php 1.6 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 Model_type_one = 1; // 退货单
  14. const Model_type_two = 2; // 换货单
  15. public static $model_type = [
  16. self::Model_type_one,
  17. self::Model_type_two,
  18. ];
  19. public static $model_type_name = [
  20. self::Model_type_one => '退货单',
  21. self::Model_type_two => '换货单',
  22. ];
  23. const State_zero = 0;//未确认
  24. const State_one = 1;//已确认
  25. public static $state = [
  26. self::State_zero => '未确认',
  27. self::State_one => '已确认',
  28. ];
  29. public static $prefix = [
  30. self::Model_type_one => 'TH',
  31. self::Model_type_two => 'HH',
  32. ];
  33. public static $user = [];
  34. public static $search = [];
  35. public static $is_search = false;
  36. public function __construct(array $attributes = [])
  37. {
  38. if(! empty($attributes['userData'])) {
  39. self::$user = $attributes['userData'];
  40. self::$search = $attributes['search'];
  41. self::$is_search = true;
  42. }
  43. parent::__construct($attributes);
  44. }
  45. protected static function boot(){
  46. parent::boot();
  47. if(self::$is_search){
  48. static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  49. }
  50. }
  51. }