Question: So, I have an `'is_abandoned'` boolean on one of my tables, where if it's `true`, I'd like the model to be automatically excluded from any query - just like softDeletes does. 

Is there something I can set in the model that'd achieve this? I'm leaning towards maybe a mutator?

Answer: 
**These are called [Global Query Scopes](https://laravel.com/docs/5.4/eloquent#query-scopes).**

> 
> Writing a global scope is simple. Define a class that implements the `Illuminate\Database\Eloquent\Scope` interface. This interface requires you to implement one method: `apply`. The `apply` method may add `where` constraints to the query as needed:
> 
> 
> 

```
<?php

namespace App\Scopes;

use Illuminate\Database\Eloquent\Scope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;

class AgeScope implements Scope
{
    /**
     * Apply the scope to a given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @return void
     */
    public function apply(Builder $builder, Model $model)
    {
        $builder->where('age', '>', 200);
    }
}

```

> 
> To assign a global scope to a model, you should override a given model's `boot` method and use the `addGlobalScope` method:
> 
> 
> 

```
<?php

namespace App;

use App\Scopes\AgeScope;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * The "booting" method of the model.
     *
     * @return void
     */
    protected static function boot()
    {
        parent::boot();

        static::addGlobalScope(new AgeScope);
    }
}

```
You can just exclude the record using eloquent where function

```
$lists = List::where('is_abandoned',false);

```