From b14f0d6b63cd58b059b968c5e0bc64816204d9e8 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Wed, 13 Sep 2023 09:36:31 +0930 Subject: [PATCH] rename config variable --- README.md | 24 ++++++++++-------------- config/model-uuid.php | 3 +-- src/GeneratesUuid.php | 2 +- tests/Feature/GeneratesUuidTest.php | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 64cc8a5..487b17f 100644 --- a/README.md +++ b/README.md @@ -67,22 +67,11 @@ class Post extends Model } ``` -A default column name can also be configured. Simply create a config file called `config/model-uuid.php` and edit its contents. For example, to change the default UUID column name to `uuid_binary`, modify your `config/model-uuid.php` like so: +The package will use `uuid` as the column name to store the generated UUID value by default. If you prefer a different name, you may change the `model-uuid.column_name` config variable. -```php - 'uuid_binary', -]; - -``` +You may also override the `uuidColumn` method on a per-model basis. -By default, this package will use UUID version 4 values, however, you are welcome to use `uuid1`, `uuid4`, or `uuid6` by specifying the protected property `$uuidVersion` in your model. Should you wish to take advantage of [ordered UUID (version 4) values that were introduced in Laravel 5.6](https://laravel.com/docs/master/helpers#method-str-ordered-uuid), you should specify `ordered` as the `$uuidVersion` in your model. +By default, this package will use UUID version 4 values, however, you are welcome to use `uuid1`, `uuid4`, `uuid6`, or `uuid7` by specifying the protected property `$uuidVersion` in your model. Should you wish to take advantage of [ordered UUID (version 4) values that were introduced in Laravel 5.6](https://laravel.com/docs/master/helpers#method-str-ordered-uuid), you should specify `ordered` as the `$uuidVersion` in your model. ```php 'uuid', + 'column_name' => 'uuid', ]; diff --git a/src/GeneratesUuid.php b/src/GeneratesUuid.php index b6ae9e6..7b47fdb 100644 --- a/src/GeneratesUuid.php +++ b/src/GeneratesUuid.php @@ -72,7 +72,7 @@ public static function bootGeneratesUuid(): void */ public function uuidColumn(): string { - return config('model-uuid.default_column_name', 'uuid'); + return config('model-uuid.column_name', 'uuid'); } /** diff --git a/tests/Feature/GeneratesUuidTest.php b/tests/Feature/GeneratesUuidTest.php index 4ff05a0..4082769 100644 --- a/tests/Feature/GeneratesUuidTest.php +++ b/tests/Feature/GeneratesUuidTest.php @@ -24,7 +24,7 @@ public function it_gets_default_column_name() 'The UUID column should be "uuid" when no default is configured.' ); - Config::set('model-uuid.default_column_name', 'uuid_custom'); + Config::set('model-uuid.column_name', 'uuid_custom'); $this->assertSame( $testModelThatGeneratesUuid->uuidColumn(), 'uuid_custom',