ReturnExchangeOrder.php 1.3 KB

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