fix(bio): add BioPageFactory, newFactory() override on BioPage

main
boban 2026-05-16 08:12:54 +02:00
parent e9623b9b31
commit a394e0ff18
2 changed files with 34 additions and 0 deletions

View File

@ -22,6 +22,11 @@ class BioPage extends Model
'ulid' => 'string',
];
protected static function newFactory(): \Database\Factories\BioPageFactory
{
return \Database\Factories\BioPageFactory::new();
}
protected static function booted(): void
{
static::creating(function (self $model) {

View File

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Domains\Bio\Models\BioPage;
use App\Domains\Workspace\Models\Workspace;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class BioPageFactory extends Factory
{
protected $model = BioPage::class;
public function definition(): array
{
$user = User::factory()->create();
$workspace = (new \App\Domains\Workspace\Actions\CreateWorkspace)->handle($user, ['name' => 'Test']);
return [
'workspace_id' => $workspace->id,
'slug' => Str::slug(fake()->words(2, true)),
'title' => ['en' => fake()->sentence(4), 'de' => fake()->sentence(4)],
'description' => ['en' => fake()->sentence(), 'de' => fake()->sentence()],
'theme' => [],
'is_published' => true,
];
}
}