think.studio / laravel-blocklist-check
Simple blocklist validator for laravel.
2.1.0
2023-08-19 17:58 UTC
Requires
- php: ^8.1
- illuminate/support: ^9.0|^10.0
- think.studio/php-blocklist-check: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.1
- psalm/plugin-laravel: ^2.8
- vimeo/psalm: ^5.11
README
Add model to blocklist/allowlist,
Installation
Install the package via composer:
composer require think.studio/laravel-blocklist-check
Optionally you can publish the config file with:
php artisan vendor:publish --provider="LaraBlockList\ServiceProvider" --tag="config"
Usage
Update your model:
use LaraBlockList\Contracts\CanBeInBlocklist; use LaraBlockList\Models\HasBlocklist; class User /* ... */ implements CanBeInBlocklist { use HasBlocklist; /** * @inheritDoc */ public function getBlocklistProcessor(array $args = []): BlocklistProcessor { return new BlocklistProcessor([ new RegexChecker([ '/\.ru$/', ], [ 'email' ]), new RegexChecker([ /* contain cyrillic */ '/[А-Яа-яЁё]+/u', ], [ 'name', ]), ]); } // ... }
Now you can run checks:
php artisan blocklist:check "\App\Models\User" # or php artisan blocklist:check "\App\Models\User" 123 # or php artisan blocklist:check "\App\Models\User" --from=2020-01-01 --queue=default