Skip to content

Latest commit

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

model-scope

中文说明

Latest Stable VersionTotal DownloadsLicense

The model scope annotation for Hyperf.

Installation

composer require friendsofhyperf/model-scope

Usage

  • Define a scope
namespaceApp\Model\Scope;
useHyperf\Database\Model\Builder;
useHyperf\Database\Model\Model;
useHyperf\Database\Model\Scope;
class AncientScope implements Scope
{
/** * Apply the scope to a given Model query builder. */publicfunctionapply(Builder$builder, Model$model): void
{
$builder->where('created_at', '<', now()->subYears(2000));
}
}
  • Binding on model
namespaceApp\Model;
useApp\Model\Scope\AncientScope;
useFriendsOfHyperf\ModelScope\Annotation\ScopedBy;
#[ScopedBy(AncientScope::class)]
class User extends Model
{
//
}

Contact

License

MIT

About

[READ-ONLY] Model scope annotation for Hyperf.

Resources

Security policy

Stars

0 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages