承接 frictionlessdigital/uuidable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

frictionlessdigital/uuidable

最新稳定版本:12.0.0

Composer 安装命令:

composer create-project frictionlessdigital/uuidable

包简介

Frictionless Solutions | Uuidable

关键字:

README 文档

README

Add UUID behavior to your Eloquent models.

Installation

composer require "frictionlessdigital/uuidable":"^1.0"

Note that root namespace for the package is Fls not Frictionlessditial.

Config

The package does not require configuration.

Integration

To add behavior to your model, simply import the trait:

use Fls\Uuidable\Uuidable;

class User extends Model
{
    use Uuidable;
    ...
}

If you want to update the field to within which the UUID is stored, define a static model propery like so:

use Fls\Uuidable\Uuidable;

class User extends Model
{
    use Uuidable;
    ...

    /**
     * Name of the field to to store the UUID
     *
     * @var string
     */
    const UUID = 'diuu';
}

Usage

Fls\Uuidable\Uuidable trait adds a number of methods to your model:

Uuidable::findByUuid

Similar to find($key), findByUuid($uuid) will locate the first Uuidable model where the value of the fild matches the argument.

$user  = User::findByUuid(string $uuid);

You can also pass an array of column you want to hydrate from the database as a second argument:

$user  = User::findByUuid(string $uuid, ['email', 'password']);

Under the hood the method relies on whereUuid()

Uuidable::whereUuid()

Scope the model by uuid value. You can use a string value, an array, pass in Arrayable class. N.B. if you pass an Eloquent Collection, it will be parsed for its model keys, which will be passed as a scoping argument.

$builder  = User::whereUuid(string $uuid);

or

$builder  = User::whereUuid([$uuid]);

or

$builder  = User::whereUuid(collect([$uuid]));

or

$builder  = User::whereUuid(Users::pluck('uuid'));

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email support@frictionlesssolutions.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 238
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-04