-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
return [ | ||
/** | ||
* The default column name which should be used to store the generated UUID value. | ||
*/ | ||
'column_name' => 'uuid', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Dyrynda\Database\Support; | ||
|
||
use Spatie\LaravelPackageTools\Commands\InstallCommand; | ||
use Spatie\LaravelPackageTools\Package; | ||
use Spatie\LaravelPackageTools\PackageServiceProvider; | ||
|
||
class LaravelModelUuidServiceProvider extends PackageServiceProvider | ||
{ | ||
public function configurePackage(Package $package): void | ||
{ | ||
$package | ||
->name('model-uuid') | ||
->hasConfigFile() | ||
->hasInstallCommand(function (InstallCommand $command) { | ||
$command->publishConfigFile(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Config; | ||
use Dyrynda\Database\Support\GeneratesUuid; | ||
use Tests\TestCase; | ||
|
||
class GeneratesUuidTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_gets_default_column_name() | ||
{ | ||
$testModelThatGeneratesUuid = new class() | ||
{ | ||
use GeneratesUuid; | ||
}; | ||
|
||
$this->assertSame( | ||
$testModelThatGeneratesUuid->uuidColumn(), | ||
'uuid', | ||
'The UUID column should be "uuid" when no default is configured.' | ||
); | ||
|
||
Config::set('model-uuid.column_name', 'uuid_custom'); | ||
$this->assertSame( | ||
$testModelThatGeneratesUuid->uuidColumn(), | ||
'uuid_custom', | ||
'The UUID column should match the configured value.' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters