diff --git a/README.md b/README.md index 579d686..79da267 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,6 @@ You can install the package via composer: composer require hyperlink/laravel-created-by ``` -You can publish the config file with: - -```bash -php artisan vendor:publish --tag="laravel-created-by-config" -``` - -This is the contents of the published config file: - -```php -return [ -]; -``` - ## Usage ```php diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/created-by.php b/config/created-by.php deleted file mode 100644 index 76e4963..0000000 --- a/config/created-by.php +++ /dev/null @@ -1,6 +0,0 @@ -comment('All done'); - - return self::SUCCESS; - } -} diff --git a/src/CreatedByServiceProvider.php b/src/CreatedByServiceProvider.php index 5c76d46..ded230c 100644 --- a/src/CreatedByServiceProvider.php +++ b/src/CreatedByServiceProvider.php @@ -17,8 +17,7 @@ public function configurePackage(Package $package): void * More info: https://github.com/spatie/laravel-package-tools */ $package - ->name('laravel-created-by') - ->hasConfigFile(); + ->name('laravel-created-by'); } public function packageRegistered(): void diff --git a/tests/BlueprintMacroTest.php b/tests/BlueprintMacroTest.php new file mode 100644 index 0000000..2b95ded --- /dev/null +++ b/tests/BlueprintMacroTest.php @@ -0,0 +1,42 @@ + 'created_by', + 'updatedBy' => 'updated_by', + 'deletedBy' => 'deleted_by', + 'restoredBy' => 'restored_by', +] as $functionName => $columnName) { + it('can extend the blueprint for migrations - '.$functionName, function () use ($functionName, $columnName) { + app()->register(CreatedByServiceProvider::class); + + $blueprint = new Blueprint('test'); + $blueprint->$functionName(); + expect($blueprint->getAddedColumns())->toHaveCount(1); + expect($blueprint->getAddedColumns()[0]->toArray())->toEqual([ + 'type' => 'bigInteger', + 'name' => $columnName, + 'autoIncrement' => false, + 'unsigned' => true, + 'nullable' => true, + 'default' => null, + ]); + }); +} + +it('can extend the blueprint for migrations - restoredAt', function () { + app()->register(CreatedByServiceProvider::class); + + $blueprint = new Blueprint('test'); + $blueprint->restoredAt(); + expect($blueprint->getAddedColumns())->toHaveCount(1); + expect($blueprint->getAddedColumns()[0]->toArray())->toEqual([ + 'type' => 'timestamp', + 'name' => 'restored_at', + 'precision' => 0, + 'nullable' => true, + 'default' => null, + ]); +}); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php deleted file mode 100644 index 5d36321..0000000 --- a/tests/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -});