fix(bio): add BioPageFactory, newFactory() override on BioPage
parent
e9623b9b31
commit
a394e0ff18
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue