thtg88 / laravel-exists-without-soft-deleted-rule
Provide a Laravel `exists` validation rule that excludes soft-deleted models.
Installs: 16 049
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- illuminate/container: ^7.0.0 || ^8.0.0
- illuminate/contracts: ^7.0.0 || ^8.0.0
- illuminate/support: ^7.0.0 || ^8.0.0
- illuminate/validation: ^7.0.0 || ^8.0.0
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- friendsofphp/php-cs-fixer: ^2.16
- fzaninotto/faker: ^1.9
- orchestra/testbench: ^5.1
- phpstan/phpstan: ^0.12.14
- phpunit/phpunit: ^8.1
This package is auto-updated.
Last update: 2024-10-26 18:54:48 UTC
README
Most of my applications use models with the SoftDeletes
trait.
Therefore on all my validation rules I always have to specify the whereNull
additional statement to an exists
validation rule.
This package provide a shortcut exists_without_soft_deleted
rule for it.
Table of Contents
Installation
composer require thtg88/laravel-exists-without-soft-deleted-rule
You can publish the configuration file and views by running:
php artisan vendor:publish --provider="Thtg88\ExistsWithoutSoftDeletedRule\ExistsWithoutSoftDeletedRuleServiceProvider"
Usage
Laravel Exists Without Soft Deleted Validation Rule exposes a validation rule to check existence of a model, without soft-deleted ones.
Validation Rule
The validation rule is available using exists_without_soft_deleted
.
If you are validating the name
attribute on the users
table for example, you can use the rule as:
'name' => 'exists_without_soft_deleted:users',
For other example of usage, it's equivalent to Laravel's exists
rule.
See the official Laravel documentation for more information
License
Laravel Exists Without Soft Deleted Validation Rule is open-sourced software licensed under the MIT license.
Security Vulnerabilities
If you discover a security vulnerability within Laravel Exists Without Soft Deleted Validation Rule, please send an e-mail to Marco Marassi at security@marco-marassi.com. All security vulnerabilities will be promptly addressed.