soyhuce/laravel-eloquent-extended

Eloquent 的一些实用扩展

1.6.0 2024-08-21 09:02 UTC

This package is auto-updated.

Last update: 2024-09-21 09:15:11 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status GitHub PHPStan Action Status Total Downloads

这里应该放置您的描述。尽量限制为一到两段。可以考虑添加一个小例子。

安装

您可以通过 composer 安装此包

composer require soyhuce/laravel-eloquent-extended

使用方法

构建器

杂项

  • Builder::scope(Illuminate\Database\Eloquent\Scope $score): Builder
  • Builder::scoped(\Closure $callable): Builder

排序

  • Builder::preventInvalidDirection(string $direction): void
  • Builder::orderByNullsLast(string $column, string $direction = 'asc'): Builder
  • Builder::orderByRawNullsLast(string $sql): Builder
  • Builder::orderByAggregate( string $relationName, string $column, string $direction = 'asc', ?string $function = null, ?Closure $constraints = null)
  • Builder::orderByExists(string $relation, ?Closure $constraints = null, string $direction = 'asc')
  • Builder::orderByExistsDesc(string $relation, ?Closure $constraints = null)
  • Builder::orderByCount(string $relation, ?Closure $constraints = null, string $direction = 'asc')
  • Builder::orderByCountDesc(string $relation, ?Closure $constraints = null)
  • Builder::orderBySum(string $relation, string $column, ?Closure $constraints = null, string $direction = 'asc')
  • Builder::orderBySumDesc(string $relation, string $column, ?Closure $constraints = null)
  • Builder::orderByMin(string $relation, string $column, ?Closure $constraints = null, string $direction = 'asc')
  • Builder::orderByMinDesc(string $relation, string $column, ?Closure $constraints = null)
  • Builder::orderByMax(string $relation, string $column, ?Closure $constraints = null, string $direction = 'asc')
  • Builder::orderByMaxDesc(string $relation, string $column, ?Closure $constraints = null)

结果

  • Builder::random(): Model

选择

  • Builder::withAggregateFunction( $relations, \Soyhuce\EloquentExtended\Aggregates\Contracts\AggregateFunction $aggregateFunction): Builder
  • Builder::withAnyExists(array $relations, string $alias = 'related_exists') : Builder
  • Builder::withImplode($relations, string $column, string $glue, ?string $orderBy = null, string $direction = 'asc') : Builder

创建

  • Builder::insertModels(array $values): bool
  • Builder::upsertModels(array $values, string|array $uniqueBy, ?array $update = null): int
  • Builder::insertModelsReturning(array $values, array $returning = ['*']): Collection (requires tpetry/laravel-postgresql-enhanced)
  • Builder::upsertModelsReturning(array $values, string|array $uniqueBy, ?array $update = null, array $returning = ['*']): Collection (requires tpetry/laravel-postgresql-enhanced)

Eloquent 集合

  • Collection::loadAttributes(Closure(Builder): Builder|void $loadWith): Collection

模型特性

加载属性

  • Model::loadAttributes(Closure(Builder): Builder|void $loadWith): Model

测试

composer test

变更日志

请参阅 CHANGELOG 以获取最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全漏洞

请查阅 我们的安全策略 了解如何报告安全漏洞。

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。