12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Model;
- use App\Scopes\DepartmentScope;
- use Illuminate\Database\Eloquent\Model;
- class ReturnExchangeOrder extends Model
- {
- protected $fillable = ['userData'];
- protected $table = "return_exchange_order"; //指定表
- const CREATED_AT = 'crt_time';
- const UPDATED_AT = 'upd_time';
- protected $dateFormat = 'U';
- const Model_type_one = 1; // 退货单
- const Model_type_two = 2; // 换货单
- public static $model_type = [
- self::Model_type_one,
- self::Model_type_two,
- ];
- const State_zero = 0;//未确认
- const State_one = 1;//已确认
- public static $state = [
- self::State_zero => '未确认',
- self::State_one => '已确认',
- ];
- public static $prefix = [
- self::Model_type_one => 'TH',
- self::Model_type_two => 'HH',
- ];
- public static $user = [];
- public static $is_search = false;
- public function __construct(array $attributes = [])
- {
- if(! empty($attributes['userData'])) {
- self::$user = $attributes['userData'];
- self::$is_search = true;
- }
- parent::__construct($attributes);
- }
- protected static function boot(){
- parent::boot();
- if(self::$is_search){
- static::addGlobalScope(new DepartmentScope(self::$user));
- }
- }
- }
|