Skip to content

Commit

Permalink
Allow a false PK (#28)
Browse files Browse the repository at this point in the history
* Allow a false PK

* StyleCI fix
  • Loading branch information
specialtactics authored Mar 1, 2020
1 parent 2675a44 commit e912b36
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/RestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/RestfulModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down

0 comments on commit e912b36

Please sign in to comment.