PHPackages                             claver/smart-query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. claver/smart-query

ActiveLibrary[Database &amp; ORM](/categories/database)

claver/smart-query
==================

Making queries much easier in your laravel application

0.0.3(1y ago)214MITPHPPHP ^8.0

Since Nov 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Limitless-Kode/smart-model)[ Packagist](https://packagist.org/packages/claver/smart-query)[ RSS](/packages/claver-smart-query/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel Smart Query
===================

[](#laravel-smart-query)

[![wakatime](https://camo.githubusercontent.com/693fbd298358758bb1f04a44af9660df34d575f34976ef7e3b379cf632aeab12/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f4c696d69746c6573732d4b6f64652f736d6172742d6d6f64656c2e737667)](https://wakatime.com/badge/github/Limitless-Kode/smart-model)

Introduction
------------

[](#introduction)

Smart-Query is a Laravel package that utilizes spatie-query-builder to enable smart queries with minimal configuration. With this package, you can create powerful, dynamic queries by simply adding the HasSmartQuery trait to your models.

Installation
------------

[](#installation)

To install Smart-Query, you need to have a Laravel application set up. Then, you can install the package via composer by running the command:

```
composer require claver/smart-query
```

After installing the package, you need to register the `SmartQueryServiceProvider` in your `config > app.php`

```
'providers' => [
	...,
	\Claver\SmartQuery\Providers\SmartQueryServiceProvider::class,
	...
]
```

```
php artisan vendor:publish --provider="Spatie\\QueryBuilder\\QueryBuilderServicProvider" --tag="config"
```

This will publish the `query-builder.php` file to your `config` directory.

Usage
-----

[](#usage)

To use Smart-Query, add the `HasSmartQuery` trait to any model you want to enable smart queries on.

```
use Claver\SmartQuery\HasSmartQuery;

class User extends Model{
	use HasSmartQuery;
}
```

This trait provides a `resolve` method, which you can use to apply smart queries to your model. you can also `@override` the method name to any name if you do not like the name `resolve`

```
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Claver\SmartQuery\HasSmartQuery;

class User extends Model{
	use HasSmartQuery;

	public function customName(): LengthAwarePaginator|ResourceCollection
    {
        parent::resolve();
    }
}
```

Finally, you can call your custom method name or resolve if you didn't change the default name.

```
class UserController extends Controller{
	public function index(Request $request){
		$users = (new User())->resolve();
		return response()->json($users);
	}
}
```

The `smartQuery` method will apply any filters, sorts, includes, and fields specified in the query string to the model.

To learn more about how to make simple and advanced queries, visit [**Spatie-Query-Builder**](https://spatie.be/docs/laravel-query-builder/v5/features)

You do not have to create your own query builder every single time you need it. Just override these methods.

MethodDescriptiongetAllowedFiltersReturns an array that includes all the fields that could be filteredgetAllowedIncludesReturns an array that includes all the relationships that could be includedgetAllowedSortsReturns an array that includes all the fields that could be sorted. you don't need to include this method because it's dynamically generatedConclusion
----------

[](#conclusion)

Smart-Query is a powerful package that simplifies creating dynamic queries in Laravel. By using the `HasSmartQuery` trait, you can take advantage of the `spatie-query-builder` package and create smart queries with minimal configuration.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

592d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef39a8d89366df1d276493e523d9d2bc3c6afb110e15388771e14bc49cbf44c5?d=identicon)[limitless](/maintainers/limitless)

---

Top Contributors

[![rockclaver](https://avatars.githubusercontent.com/u/57482239?v=4)](https://github.com/rockclaver "rockclaver (22 commits)")

---

Tags

claversmart-query

### Embed Badge

![Health badge](/badges/claver-smart-query/health.svg)

```
[![Health](https://phpackages.com/badges/claver-smart-query/health.svg)](https://phpackages.com/packages/claver-smart-query)
```

###  Alternatives

[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.4k](/packages/typicms-base)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
