first
This commit is contained in:
53
database/factories/TranscriptionProjectFactory.php
Normal file
53
database/factories/TranscriptionProjectFactory.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\TranscriptionProject;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<TranscriptionProject> */
|
||||
class TranscriptionProjectFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'title' => fake()->sentence(4),
|
||||
'description' => fake()->optional()->sentence(),
|
||||
'owner_user_id' => User::factory(),
|
||||
'original_filename' => fake()->word() . '.mp3',
|
||||
'stored_audio_path' => 'transcriptions/' . Str::uuid() . '/audio/' . Str::random(20) . '.mp3',
|
||||
'mime_type' => 'audio/mpeg',
|
||||
'file_size' => fake()->numberBetween(100000, 50000000),
|
||||
'duration_seconds' => fake()->optional()->numberBetween(60, 3600),
|
||||
'language' => 'ms',
|
||||
'transcription_status' => 'pending',
|
||||
'transcription_engine' => 'faster-whisper',
|
||||
'transcript_text' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'transcription_status' => 'completed',
|
||||
'transcript_text' => fake()->paragraphs(3, true),
|
||||
'processed_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function failed(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'transcription_status' => 'failed',
|
||||
'error_message' => 'Connection refused',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processing(): static
|
||||
{
|
||||
return $this->state(fn () => ['transcription_status' => 'processing']);
|
||||
}
|
||||
}
|
||||
43
database/factories/UserFactory.php
Normal file
43
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<User> */
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
protected static ?string $password;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'role' => 'user',
|
||||
'department_id' => null,
|
||||
'is_active' => true,
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
public function admin(): static
|
||||
{
|
||||
return $this->state(fn () => ['role' => 'admin']);
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(fn () => ['is_active' => false]);
|
||||
}
|
||||
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn () => ['email_verified_at' => null]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user