I need to use withoutGlobalScope()
if condition true. I have tried it with when function. But it only work outside of the function.
this is my model
protected static function boot()
{
parent::boot();
static::addGlobalScope('active', function (Builder $builder) {
$builder->where('vehicles.active', 0);
});
}
here is the eloquent query
$this->model
->when((isset($attbutes->inactive) && $attbutes->inactive==1), function ($q) use ($attbutes) {
return $q->withoutGlobalScope('active');
})
->get();