friendsofhyperf/model-scope
最新稳定版本:v3.2.0-alpha.6
Composer 安装命令:
composer require friendsofhyperf/model-scope
包简介
The model scope annotation for Hyperf.
README 文档
README
The model scope annotation for Hyperf.
Installation
composer require friendsofhyperf/model-scope
Usage
- Define a scope
namespace App\Model\Scope; use Hyperf\Database\Model\Builder; use Hyperf\Database\Model\Model; use Hyperf\Database\Model\Scope; class AncientScope implements Scope { /** * Apply the scope to a given Model query builder. */ public function apply(Builder $builder, Model $model): void { $builder->where('created_at', '<', now()->subYears(2000)); } }
- Binding on model
namespace App\Model; use App\Model\Scope\AncientScope; use FriendsOfHyperf\ModelScope\Annotation\ScopedBy; #[ScopedBy(AncientScope::class)] class User extends Model { // }
Contact
License
统计信息
- 总下载量: 210
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-20