From cee396e816718f67bc69102da5f5d708f9361528 Mon Sep 17 00:00:00 2001 From: Emad Adly Date: Wed, 21 Jun 2017 17:41:52 +0200 Subject: [PATCH 1/3] No longer needed to register No need for him after update `uuid` generator to [ramsey uuid](https://github.com/ramsey/uuid) method instead of our own method , at the suggestion of [#3](https://github.com/EmadAdly/laravel-uuid/issues/3) --- src/LaravelUuidServiceProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/LaravelUuidServiceProvider.php b/src/LaravelUuidServiceProvider.php index 94a7700..3b9b9a5 100644 --- a/src/LaravelUuidServiceProvider.php +++ b/src/LaravelUuidServiceProvider.php @@ -34,8 +34,6 @@ public function boot() */ public function register() { - $this->app->singleton(UUIDManager::class, function () { - return new UUIDManager(); - }); + // } } From 4c5eb5003acefe96d58edea0c6e9807bb92f241a Mon Sep 17 00:00:00 2001 From: Emad Adly Date: Wed, 21 Jun 2017 17:47:05 +0200 Subject: [PATCH 2/3] not required No need for him after update `uuid` generator to [ramsey uuid](https://github.com/ramsey/uuid) method instead of our own method , at the suggestion of [#3](https://github.com/EmadAdly/laravel-uuid/issues/3) --- src/UUIDManager.php | 53 --------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/UUIDManager.php diff --git a/src/UUIDManager.php b/src/UUIDManager.php deleted file mode 100644 index aa6e4a3..0000000 --- a/src/UUIDManager.php +++ /dev/null @@ -1,53 +0,0 @@ -generate(); - - $this->uuid = $uuid; - - return $uuid; - } - -/* public function __toString() - { - return $this->uuid; - }*/ - - - /** - * - * This function will return a UUID - * - * @return type string - */ - public static function generate() - { - - mt_srand((double)microtime()*10000); - $charid = strtoupper(md5(uniqid(rand(), true))); - $hyphen = chr(45);// "-" - $uuid = chr(123)// "{" - .substr($charid, 0, 8).$hyphen - .substr($charid, 8, 4).$hyphen - .substr($charid,12, 4).$hyphen - .substr($charid,16, 4).$hyphen - .substr($charid,20,12) - .chr(125);// "}" - - $uuid = str_replace('{', '' , $uuid); - $uuid = str_replace('}', '' , $uuid); - - return $uuid; - - } -} \ No newline at end of file From 7b4d83d5eed95df1b052c535ef9ac4bc9a7adc88 Mon Sep 17 00:00:00 2001 From: Emad Adly Date: Wed, 21 Jun 2017 17:51:15 +0200 Subject: [PATCH 3/3] Update to call new method No need for him after update `uuid` generator to [ramsey uuid](https://github.com/ramsey/uuid) method instead of our own method , at the suggestion of [#3](https://github.com/EmadAdly/laravel-uuid/issues/3) --- src/Uuids.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Uuids.php b/src/Uuids.php index 4a2a92c..132ff18 100644 --- a/src/Uuids.php +++ b/src/Uuids.php @@ -1,7 +1,7 @@ {config('uuid.default_uuid_column')} = UUIDManager::generate(); + $model->{config('uuid.default_uuid_column')} = strtoupper(Uuid::uuid4()->toString()); }); static::saving(function ($model) { $original_uuid = $model->getOriginal(config('uuid.default_uuid_column')); @@ -43,4 +43,4 @@ public function scopeUuid($query, $uuid, $first = true) return $first ? $results->firstOrFail() : $results; } -} \ No newline at end of file +}