koutech/class-base-filter

Top layer for spatie-query-builder with class base filter and other featuer too.

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/koutech/class-base-filter

v1.0 2020-06-04 14:27 UTC

This package is auto-updated.

Last update: 2025-09-23 01:16:31 UTC


README

composer require koutech/class-base-filter

Class Base Filter

  • Go to the app folder and create a folder name called Filter
  • Create Some class e.g UserFilter.php

Inside Filter Class

all you have to do is just extend the Koutech\TopLayerForSpatieQueryBuilder\Filter contain at least two methods fields and model inside class

<?php 

namespace App\Filter;

use Koutech\TopLayerForSpatieQueryBuilder\Filter;

use App\User;


class UserFilter extends Filter
{

    public function model() 
    {
        return User::class;
    }
    
    public function fields() 
    {
        return ['name'];
    }


}

Usage

<?php

$users = UserFilter::filter()->get();

Set Eager Loading

contain method called include inside class example if you want to contain post that belongs to the user all you have to do is...

<?php 

public function eagerLoading() 
{
    return ['post'];
}

Set Eager Loading From Url

contain method called include inside class example if you want to contain post that belongs to the user all you have to do is...

<?php 

public function includes() 
{
    return ['post'];
}