Skip to content

Commit

Permalink
Merge pull request #27 from envor/main
Browse files Browse the repository at this point in the history
main
  • Loading branch information
inmanturbo authored Aug 2, 2024
2 parents 235e4e7 + aa5d4fd commit 950121a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to `laravel-datastore` will be documented in this file.

## v1.2.18 - 2024-08-02

### What's Changed

* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/envor/laravel-datastore/pull/25
* Limit recursion with a couple assertions by @inmanturbo in https://github.com/envor/laravel-datastore/pull/26

**Full Changelog**: https://github.com/envor/laravel-datastore/compare/v1.2.17...v1.2.18

## v1.2.17 - 2024-07-03

### What's Changed
Expand Down
13 changes: 12 additions & 1 deletion src/Concerns/BelongsToDatastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ public function getDatastoreDriver(): ?string
return $this->datastore_driver;
}

public function generateDatastoreName(): string
{
if (isset($this->name) && isset($this->uuid)) {
$uuid = substr($this->uuid, -4);

return (string) str()->of($this->name)->slug('_')->finish('_'.$uuid)->lower();
}

return (string) str()->ulid();
}

protected function createDatastore(): Model
{
$model = config('datastore.model');
$auth = config('auth.providers.users.model');

$attributes = [
'name' => (string) str()->of($this->name)->slug('_'),
'name' => $this->generateDatastoreName(),
'driver' => $this->getDatastoreDriver() ?? $model::DEFAULT_DRIVER,
];

Expand Down

0 comments on commit 950121a

Please sign in to comment.