mrmadclown / laravel-utilities
Requires
- php: ^8.0
- ext-json: *
- illuminate/console: ^8.0
- illuminate/database: ^8.0
- illuminate/support: ^8.0
- psr/log: ^1.1
This package is auto-updated.
Last update: 2024-09-19 12:06:40 UTC
README
安装
composer require mrmadclown/laravel-utilities
使用
如果您不使用自动发现,请将 ServiceProvider 添加到 config/app.php 中的 providers 数组中
MrMadClown\LaravelUtilities\ServiceProvider::class,
命令
ListModelsCommand 命令接受一个 ModelClass(或形态别名)和多个过滤参数。过滤结构:[列名]:[运算符][值],或者您也可以省略运算符 [列名][值](将解析为 '=')。'*' 将解析为 'CONTAINS'。
php artisan app:list user php artisan app:list \App\User::class php artisan app:list user first_name:luc php artisan app:list user age:<26 php artisan app:list user first_name:luc age:<26 php artisan app:list user first_name:luc age:<26
ScheduleListCommand 基本上显示所有计划任务的表格
php artisan schedule:list
CheckDatabaseSize 命令显示您的数据库占用的空间量。
php artisan app:db:check-size
特质
UsesUUID 使用 uuid 替换模型键
use \MrMadClown\LaravelUtilities\Database\Eloquent\Model\UsesUUID;
助手
解析 (HEROKU env) 连接字符串到 LARAVEL 配置数组
use function \MrMadClown\LaravelUtilities\parse_pusher_url; use function \MrMadClown\LaravelUtilities\parse_mysql_url;
作业中间件
Funnel
Funnel 作业,构造函数参数为 $limit=1
,$funnelKey=get_class($job)
和 $delay=10
。作业可以实现 \MrMadClown\LaravelUtilities\Jobs\ProvidesFunnelKey
来在运行时提供 $funnelKey
。
use \MrMadClown\LaravelUtilities\Jobs\Middleware\Funnel; function middleware(){ return [new Funnel]; }
Throttle
Throttle 作业,构造函数参数为 $limit=1
,$throttleKey=get_class($job)
和 $delay=10
。作业可以实现 \MrMadClown\LaravelUtilities\Jobs\ProvidesThrottleKey
来在运行时提供 $throttleKey
。
use \MrMadClown\LaravelUtilities\Jobs\Middleware\Throttle; function middleware(){ return [new Throttle]; }
Measure
测量作业执行时间,需要构造函数参数为 \Psr\Log\LoggerInterface
和可选的 LogLevel
。
use \MrMadClown\LaravelUtilities\Jobs\Middleware\Measure; function middleware(){ return [new Measure(logger(), \Psr\Log\LogLevel::INFO)]; }
验证规则
RecursiveRule
当嵌套数组中的每个叶子都通过给定的 \Illuminate\Validation\Rule
时,该规则通过
use \MrMadClown\LaravelUtilities\Validation\Rules\RecursiveRule; new RecursiveRule(new SomeRule());
OrRule
当任一给定的 \Illuminate\Validation\Rule
通过时,该规则通过
use \MrMadClown\LaravelUtilities\Validation\Rules\OrRule; new OrRule(new IsStringRule(), new IsIntRule());