Example of Local scopes in laravelio/laravel.io

File app/Models/Thread.php (link to Github)
// In any Model, create methods scopeXxxxxx()
// Then, you will be able to use them in Controller just like ->xxxxxx()

final class Thread extends Model implements ReplyAble, SubscriptionAble, Feedable
{
    // ... other Model methods

    public function scopeResolved(Builder $query): Builder
    {
        return $query->whereNotNull('solution_reply_id');
    }

    public function scopeActive(Builder $query): Builder
    {
        return $query->has('repliesRelation');
    }
}
File app/Http/Controllers/Forum/ThreadsController.php (link to Github)
// We use ->resolved() and ->active() from that Scope

class ThreadsController extends Controller
{
    public function overview()
    {
        // ... other method code

        if ($filter === 'resolved') {
            $threads = Thread::feedQuery()
                ->resolved()
                ->paginate(20);
        }

        if ($filter === 'active') {
            $threads = Thread::feedQuery()
                ->active()
                ->paginate(20);
        }
    }
}

Additional resources on local scopes: