diff --git a/database/.gitattributes b/database/.gitattributes deleted file mode 100644 index 85b6b06..0000000 --- a/database/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# Exclude unused files -*_testbench_*.php export-ignore -UserFactory.php export-ignore diff --git a/database/migrations/.gitattributes b/database/migrations/.gitattributes new file mode 100644 index 0000000..050593c --- /dev/null +++ b/database/migrations/.gitattributes @@ -0,0 +1 @@ +*_testbench_*.php export-ignore diff --git a/src/Models/Address.php b/src/Models/Address.php index 49dea91..5ab7703 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -31,6 +31,11 @@ class Address extends NusaAddress protected $casts = []; + protected static function newFactory() + { + return Factories\AddressFactory::new(); + } + public function getCasts() { return \array_merge(parent::getCasts(), [ diff --git a/src/Models/Concerns/Factories/WithIdentity.php b/src/Models/Concerns/Factories/WithIdentity.php index 2ee1798..759b91c 100644 --- a/src/Models/Concerns/Factories/WithIdentity.php +++ b/src/Models/Concerns/Factories/WithIdentity.php @@ -3,7 +3,6 @@ namespace Creasi\Base\Models\Concerns\Factories; use Creasi\Base\Models\Personnel; -use Database\Factories\PersonnelFactory; /** * @mixin \Illuminate\Database\Eloquent\Factories\Factory @@ -13,7 +12,7 @@ trait WithIdentity public function withIdentity(\Closure $cb = null): static { if ($cb === null) { - $cb = fn (PersonnelFactory $identity) => $identity->withProfile(); + $cb = fn ($identity) => $identity->withProfile(); } return $this->has($cb(Personnel::factory()), 'identity'); diff --git a/src/Models/Factories/.gitattributes b/src/Models/Factories/.gitattributes new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/src/Models/Factories/.gitattributes @@ -0,0 +1 @@ +UserFactory.php export-ignore diff --git a/database/factories/AddressFactory.php b/src/Models/Factories/AddressFactory.php similarity index 97% rename from database/factories/AddressFactory.php rename to src/Models/Factories/AddressFactory.php index a71f151..be60c26 100644 --- a/database/factories/AddressFactory.php +++ b/src/Models/Factories/AddressFactory.php @@ -1,6 +1,6 @@ \bcrypt($value)); diff --git a/tests/TestCase.php b/tests/TestCase.php index 9cd1c01..2181dcc 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,7 +6,6 @@ use Creasi\Base\ServiceProvider; use Creasi\Nusa\ServiceProvider as NusaServiceProvider; use Creasi\Tests\Fixtures\User; -use Database\Factories\PersonnelFactory; use Illuminate\Contracts\Config\Repository; use Illuminate\Foundation\Testing\RefreshDatabase; use Laravel\Sanctum\SanctumServiceProvider; @@ -34,7 +33,7 @@ final protected function user(array|Closure $attrs = []): User { if (! $this->currentUser?->exists) { $this->currentUser = User::factory() - ->withIdentity(fn (PersonnelFactory $p) => $p->withProfile()->withCompany(true)) + ->withIdentity(fn ($p) => $p->withProfile()->withCompany(true)) ->createOne($attrs); }