ProductActivity.php 891 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ProductActivity extends Model
  6. {
  7. // protected $fillable = ['userData'];
  8. protected $guarded = [];
  9. protected $table = "product_activity"; //指定表
  10. const CREATED_AT = 'crt_time';
  11. const UPDATED_AT = 'upd_time';
  12. protected $dateFormat = 'U';
  13. public static $user = [];
  14. public static $search = [];
  15. const range_function = '';
  16. public function __construct(array $attributes = [])
  17. {
  18. if(! empty($attributes['userData'])) {
  19. self::$user = $attributes['userData'];
  20. self::$user['range_function'] = self::range_function;
  21. self::$search = $attributes['search'] ?? [];
  22. static::addGlobalScope(new DepartmentScope(self::$user,self::$search));
  23. }
  24. parent::__construct($attributes);
  25. }
  26. }