Skip to content

Commit

Permalink
rename config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldyrynda committed Sep 13, 2023
1 parent f71a674 commit b14f0d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php

return [
/**
* The default column name which should be used to store the generated UUID value.
* Note: This can still be overwritten by declaring a `uuidColumn()` method in your model(s).
*/
'default_column_name' => '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
<?php
Expand Down Expand Up @@ -210,6 +199,13 @@ This package is installed via [Composer](https://getcomposer.org/). To install,
```bash
composer require dyrynda/laravel-model-uuid
```

If you wish to override default configuration, you may publish the configuration file to your application.

```bash
php artisan vendor:publish --tag=model-uuid-config
```

## Support

If you are having general issues with this package, feel free to contact me on [Twitter](https://twitter.com/michaeldyrynda).
Expand Down
3 changes: 1 addition & 2 deletions config/model-uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
return [
/**
* The default column name which should be used to store the generated UUID value.
* Note: This can still be overwritten by declaring a `uuidColumn()` method in your model(s).
*/
'default_column_name' => 'uuid',
'column_name' => 'uuid',
];
2 changes: 1 addition & 1 deletion src/GeneratesUuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GeneratesUuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b14f0d6

Please sign in to comment.