completed story 1.1 with QA tests and fixes
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ConsultationStatus;
|
||||
use App\Enums\ConsultationType;
|
||||
use App\Enums\PaymentStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Consultation>
|
||||
*/
|
||||
class ConsultationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$consultationType = fake()->randomElement(ConsultationType::cases());
|
||||
$paymentStatus = $consultationType === ConsultationType::Paid
|
||||
? fake()->randomElement([PaymentStatus::Pending, PaymentStatus::Received])
|
||||
: PaymentStatus::NotApplicable;
|
||||
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'booking_date' => fake()->dateTimeBetween('now', '+30 days'),
|
||||
'booking_time' => fake()->time('H:i:s'),
|
||||
'problem_summary' => fake()->paragraph(),
|
||||
'consultation_type' => $consultationType,
|
||||
'payment_amount' => $consultationType === ConsultationType::Paid ? fake()->randomFloat(2, 50, 500) : null,
|
||||
'payment_status' => $paymentStatus,
|
||||
'status' => fake()->randomElement(ConsultationStatus::cases()),
|
||||
'admin_notes' => fake()->optional()->paragraph(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a free consultation.
|
||||
*/
|
||||
public function free(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'consultation_type' => ConsultationType::Free,
|
||||
'payment_amount' => null,
|
||||
'payment_status' => PaymentStatus::NotApplicable,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a paid consultation.
|
||||
*/
|
||||
public function paid(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'consultation_type' => ConsultationType::Paid,
|
||||
'payment_amount' => fake()->randomFloat(2, 50, 500),
|
||||
'payment_status' => fake()->randomElement([PaymentStatus::Pending, PaymentStatus::Received]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pending consultation.
|
||||
*/
|
||||
public function pending(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ConsultationStatus::Pending,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an approved consultation.
|
||||
*/
|
||||
public function approved(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ConsultationStatus::Approved,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a completed consultation.
|
||||
*/
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ConsultationStatus::Completed,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user