- TemplateImageGenerator->render() now returns a typed array shape
{path: string, source_meta: array} instead of a one-off RenderedSlide
DTO. Single internal callsite, no need for a dedicated class.
- Drop the `?? 'en'` fallback on $workspace->content_language in 6
callsites: the column has a NOT NULL default of 'en' at the DB level,
so the null coalesce was dead code.
- WorkspaceFactory now seeds content_language, brand_tone, brand_font
and image_style explicitly so make() (no DB persist) produces a
complete model — DB defaults aren't applied until create().
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Account;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Workspace>
|
|
*/
|
|
class WorkspaceFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'name' => fake()->company(),
|
|
'content_language' => 'en',
|
|
'brand_tone' => 'professional',
|
|
'brand_font' => 'Inter',
|
|
'image_style' => 'cinematic',
|
|
];
|
|
}
|
|
|
|
public function configure(): static
|
|
{
|
|
return $this->afterMaking(function (Workspace $workspace) {
|
|
if (! $workspace->account_id) {
|
|
if ($workspace->user_id) {
|
|
$user = User::find($workspace->user_id);
|
|
|
|
if ($user?->account_id) {
|
|
$workspace->account_id = $user->account_id;
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
$workspace->account_id = Account::factory()->create()->id;
|
|
}
|
|
});
|
|
}
|
|
}
|