From e912b36b38aa75e3200c27573b742b823e762ab7 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 2 Mar 2020 10:49:17 +1100 Subject: [PATCH] Allow a false PK (#28) * Allow a false PK * StyleCI fix --- src/Http/Controllers/RestfulController.php | 2 +- src/Models/RestfulModel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/Controllers/RestfulController.php b/src/Http/Controllers/RestfulController.php index 2ad25bd..9a79536 100644 --- a/src/Http/Controllers/RestfulController.php +++ b/src/Http/Controllers/RestfulController.php @@ -218,7 +218,7 @@ public function delete($uuid) * @param string $endpoint * @return string $cacheKey */ - public static function getCacheKey(string $endpoint = 'getAll') : ?string + public static function getCacheKey(string $endpoint = 'getAll'): ?string { if ($endpoint == 'getAll') { return sprintf(static::CACHE_KEY_GET_ALL, static::$model); diff --git a/src/Models/RestfulModel.php b/src/Models/RestfulModel.php index 69ceb83..a489b60 100644 --- a/src/Models/RestfulModel.php +++ b/src/Models/RestfulModel.php @@ -113,7 +113,7 @@ public static function boot() // If the PK(s) are missing, generate them $uuidKeyName = $model->getKeyName(); - if (! is_array($uuidKeyName) && ! array_key_exists($uuidKeyName, $model->getAttributes())) { + if ($uuidKeyName && ! is_array($uuidKeyName) && ! array_key_exists($uuidKeyName, $model->getAttributes())) { $model->$uuidKeyName = Uuid::uuid4()->toString(); } });