ProductInventorySet.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\TopDepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ProductInventorySet extends Model
  6. {
  7. // protected $fillable = ['userData','search'];
  8. protected $guarded = [];
  9. protected $table = "depart_set"; //指定表
  10. const CREATED_AT = 'crt_time';
  11. const UPDATED_AT = 'upd_time';
  12. protected $dateFormat = 'U';
  13. const type_one = 1;//校验锁定
  14. const type_two = 2;//不校验锁定
  15. public static $user = [];
  16. public static $search = [];
  17. public static $is_search = false;
  18. public function __construct(array $attributes = [])
  19. {
  20. if(! empty($attributes['userData'])) {
  21. self::$user = $attributes['userData'];
  22. self::$search = $attributes['search'];
  23. self::$is_search = true;
  24. }
  25. parent::__construct($attributes);
  26. }
  27. protected static function boot(){
  28. parent::boot();
  29. if(self::$is_search){
  30. static::addGlobalScope(new TopDepartmentScope(self::$user, self::$search));
  31. }
  32. }
  33. }