Download the PHP package protonemedia/laravel-eloquent-where-not without Composer
On this page you can find all versions of the php package protonemedia/laravel-eloquent-where-not. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download protonemedia/laravel-eloquent-where-not
More information about protonemedia/laravel-eloquent-where-not
Files in protonemedia/laravel-eloquent-where-not
Package laravel-eloquent-where-not
Short Description Laravel package to invert Eloquent scopes.
License MIT
Homepage https://github.com/protonemedia/laravel-eloquent-where-not
Informations about the package laravel-eloquent-where-not
Laravel Eloquent Where Not
Included in Laravel 9.2.0!
As of Laravel 9.2.0, you may use the native whereNot
method. This package will be maintained for some time for Laravel 8 users but will be deprecated eventually.
📺 Want to see this package in action? Join the live stream on December 10 at 13:30 CET: https://youtu.be/fAY75SLQj3w
Support this package!
❤️ We proudly support the community by developing Laravel packages and giving them away for free. If this package saves you time or if you're relying on it professionally, please consider sponsoring the maintenance and development. Keeping track of issues and pull requests takes time, but we're happy to help!
Laravel Splade
Did you hear about Laravel Splade? 🤩
It's the magic of Inertia.js with the simplicity of Blade. Splade provides a super easy way to build Single Page Applications using Blade templates. Besides that magic SPA-feeling, it comes with more than ten components to sparkle your app and make it interactive, all without ever leaving Blade.
Requirements
- PHP 7.4+
- Laravel 8.0 or 9.0
This package is tested with GitHub Actions using MySQL 5.7, PostgreSQL 10.8 and SQLite.
Features
- Flip/invert your scope, or really any query constraint.
- Zero third-party dependencies.
Related package: Laravel Eloquent Scope as Select
Blogpost
If you want to know more about the background of this package, please read the blogpost: Apply the opposite of your Eloquent scope to the Query Builder with a Laravel package.
Installation
You can install the package via composer:
Add the macro
to the query builder, for example, in your AppServiceProvider
. By default, the name of the macro is whereNot
, but you can customize it with the first parameter of the addMacro
method.
Short API description
For a more practical explanation, check out the usage section below.
Call the whereNot
method with a Closure:
The example above can be shortened by using a string, which should be the name of the scope:
You can use an array to call multiple scopes:
Use an associative array to call dynamic scopes:
If your dynamic scopes require multiple arguments, you can use an associative array:
You can also mix dynamic and non-dynmaic scopes:
Usage
Imagine you have a Post
Eloquent model with a query scope that constraints the query to all posts that should make the front page.
Now you can fetch all posts for your front page by calling the scope method on the query:
But what if you want to fetch all posts that didn't make the front page? Using the power of this package, you can re-use your scope!
With short closures, a feature which was introduced in PHP 7.4, this can be even shorter:
Shortcuts
Instead of using a Closure, there are some shortcuts you could use (see also: Short API description):
Using a string instead of a Closure:
Using an array instead of Closure, to support multiple scopes and dynamic scopes:
Testing
Changelog
Please see CHANGELOG for more information about what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Other Laravel packages
Laravel Analytics Event Tracking
: Laravel package to easily send events to Google Analytics.Laravel Blade On Demand
: Laravel package to compile Blade templates in memory.Laravel Cross Eloquent Search
: Laravel package to search through multiple Eloquent models.Laravel Eloquent Scope as Select
: Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.Laravel FFMpeg
: This package provides an integration with FFmpeg for Laravel. The storage of the files is handled by Laravel's Filesystem.Laravel Form Components
: Blade components to rapidly build forms with Tailwind CSS Custom Forms and Bootstrap 4. Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!Laravel Paddle
: Paddle.com API integration for Laravel with support for webhooks/events.Laravel Verify New Email
: This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.Laravel WebDAV
: WebDAV driver for Laravel's Filesystem.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Pascal Baljet
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Treeware
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.