All Projects → spatie → Laravel Query Builder

spatie / Laravel Query Builder

Licence: mit
Easily build Eloquent queries from API requests

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Laravel Query Builder

Laravel Api Boilerplate
A Boilerplate Project For Laravel API's (NOT MAINTAINED)
Stars: ✭ 113 (-96.33%)
Mutual labels:  api, hacktoberfest, laravel
Laravel Api Boilerplate
Laravel API Boilerplate | Please consult the Wiki !
Stars: ✭ 300 (-90.27%)
Mutual labels:  api, hacktoberfest, laravel
Wagonwheel
Offer an online version of your Laravel emails to users.
Stars: ✭ 224 (-92.73%)
Mutual labels:  hacktoberfest, laravel
Laravel Craftsman
Laravel Craftsman CLI for easily crafting Laravel assets for any project (artisan make on steroids)
Stars: ✭ 227 (-92.64%)
Mutual labels:  hacktoberfest, laravel
Log Fake
A drop in fake logger for testing with the Laravel framework.
Stars: ✭ 254 (-91.76%)
Mutual labels:  hacktoberfest, laravel
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-92.93%)
Mutual labels:  api, hacktoberfest
Onesignal
OneSignal notifications channel for Laravel
Stars: ✭ 222 (-92.8%)
Mutual labels:  hacktoberfest, laravel
Horaires Ratp Api
Webservice pour les horaires et trafic RATP en temps réel
Stars: ✭ 232 (-92.47%)
Mutual labels:  api, hacktoberfest
Symfony Flex Backend
Symfony Flex REST API template project
Stars: ✭ 214 (-93.06%)
Mutual labels:  api, hacktoberfest
Laravel Admin Starter
A Laravel Admin Starter project with Page Builder, Roles, Impersonation, Analytics, Blog, News, Banners, FAQ, Testimonials and more
Stars: ✭ 240 (-92.22%)
Mutual labels:  hacktoberfest, laravel
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+11.84%)
Mutual labels:  api, hacktoberfest
Api Generator
PHP-code generator for Laravel framework, with complete support of JSON-API data format
Stars: ✭ 244 (-92.09%)
Mutual labels:  api, laravel
Urlhub
URL shortener web application based on the Laravel PHP Framework.
Stars: ✭ 217 (-92.96%)
Mutual labels:  hacktoberfest, laravel
Laravelpackage.com
Documentation for LaravelPackage.com: Learn to create Laravel specific PHP packages from scratch, following this open documentation.
Stars: ✭ 214 (-93.06%)
Mutual labels:  hacktoberfest, laravel
Larastan
⚗️ Adds code analysis to Laravel improving developer productivity and code quality.
Stars: ✭ 3,554 (+15.28%)
Mutual labels:  hacktoberfest, laravel
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (-93.55%)
Mutual labels:  api, hacktoberfest
Laravel Query Monitor
Simple artisan command to monitoring triggered queries
Stars: ✭ 230 (-92.54%)
Mutual labels:  hacktoberfest, laravel
Minha Receita
🏢 Sua API web para consulta de informações do CNPJ da Receita Federal
Stars: ✭ 255 (-91.73%)
Mutual labels:  api, hacktoberfest
Mercure
Server-sent live updates: protocol and reference implementation
Stars: ✭ 2,608 (-15.41%)
Mutual labels:  api, hacktoberfest
Pokeapi
The Pokémon API
Stars: ✭ 2,695 (-12.59%)
Mutual labels:  api, hacktoberfest

Build Eloquent queries from API requests

Latest Version on Packagist Test Status Code Style Status Total Downloads

This package allows you to filter, sort and include eloquent relations based on a request. The QueryBuilder used in this package extends Laravel's default Eloquent builder. This means all your favorite methods and macros are still available. Query parameter names follow the JSON API specification as closely as possible.

Basic usage

Filter a query based on a request: /users?filter[name]=John:

use Spatie\QueryBuilder\QueryBuilder;

$users = QueryBuilder::for(User::class)
    ->allowedFilters('name')
    ->get();

// all `User`s that contain the string "John" in their name

Read more about filtering features like: partial filters, exact filters, scope filters, custom filters, ignored values, default filter values, ...

Including relations based on a request: /users?include=posts:

$users = QueryBuilder::for(User::class)
    ->allowedIncludes('posts')
    ->get();

// all `User`s with their `posts` loaded

Read more about include features like: including nested relationships, including relationship count, custom includes, ...

Sorting a query based on a request: /users?sort=id:

$users = QueryBuilder::for(User::class)
    ->allowedSorts('id')
    ->get();

// all `User`s sorted by ascending id

Read more about sorting features like: custom sorts, sort direction, ...

Works together nicely with existing queries:

$query = User::where('active', true);

$userQuery = QueryBuilder::for($query) // start from an existing Builder instance
    ->withTrashed() // use your existing scopes
    ->allowedIncludes('posts', 'permissions')
    ->where('score', '>', 42); // chain on any of Laravel's query builder methods

Selecting fields for a query: /users?fields[users]=id,email

$users = QueryBuilder::for(User::class)
    ->allowedFields(['id', 'email'])
    ->get();

// the fetched `User`s will only have their id & email set

Read more about selecting fields.

Appending attributes to a query: /users?append=full_name

$users = QueryBuilder::for(User::class)
    ->allowedAppends('full_name')
    ->get()
    ->toJson();

// the resulting JSON will have the `getFullNameAttribute` attributes included

Read more about appending attributes.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-query-builder

Read the installation notes on the docs site: https://docs.spatie.be/laravel-query-builder/v3/installation-setup.

Documentation

You can find the documentation on https://docs.spatie.be/laravel-query-builder/v3.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Upgrading

Please see UPGRADING.md for details.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].