complete Complete User Request Submission section RAD-1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DocumentAssignment>
|
||||
*/
|
||||
class DocumentAssignmentFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'document_id' => Document::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'role' => fake()->randomElement(['رادیولوژیست', 'پزشک', 'تکنسین', 'سرپرست']),
|
||||
];
|
||||
}
|
||||
|
||||
public function radiologist(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'role' => 'رادیولوژیست',
|
||||
]);
|
||||
}
|
||||
|
||||
public function doctor(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'role' => 'پزشک',
|
||||
]);
|
||||
}
|
||||
|
||||
public function technician(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'role' => 'تکنسین',
|
||||
]);
|
||||
}
|
||||
|
||||
public function supervisor(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'role' => 'سرپرست',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\DocumentStatusEnum;
|
||||
use App\Enums\DocumentPriorityEnum;
|
||||
use App\Models\Pet;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Document>
|
||||
*/
|
||||
class DocumentFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'code' => fake()->unique()->numberBetween(100000, 999999),
|
||||
'modality' => fake()->randomElement(['CT', 'MRI', 'X-Ray', 'Ultrasound', 'PET']),
|
||||
'status' => fake()->randomElement(DocumentStatusEnum::cases()),
|
||||
'priority' => fake()->randomElement(DocumentPriorityEnum::cases()),
|
||||
'note' => fake()->optional()->sentence(),
|
||||
'submitted_at' => fake()->optional()->dateTimeBetween('-30 days', 'now'),
|
||||
'scan_date' => fake()->optional()->dateTimeBetween('-30 days', 'now'),
|
||||
'processing_deadline' => fake()->optional()->dateTimeBetween('now', '+30 days'),
|
||||
'finalized_at' => fake()->optional()->dateTimeBetween('-30 days', 'now'),
|
||||
'finalized_by' => fake()->optional()->randomElement(User::pluck('id')->toArray()),
|
||||
'rejection_reason' => fake()->optional()->sentence(),
|
||||
'pet_id' => Pet::factory(),
|
||||
'requester_id' => User::factory(),
|
||||
];
|
||||
}
|
||||
|
||||
public function registered(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => DocumentStatusEnum::Registered,
|
||||
'submitted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function inProgress(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => DocumentStatusEnum::InProgress,
|
||||
'submitted_at' => fake()->dateTimeBetween('-7 days', 'now'),
|
||||
'scan_date' => fake()->dateTimeBetween('-7 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => DocumentStatusEnum::Completed,
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', '-7 days'),
|
||||
'scan_date' => fake()->dateTimeBetween('-30 days', '-7 days'),
|
||||
'finalized_at' => fake()->dateTimeBetween('-7 days', 'now'),
|
||||
'finalized_by' => User::factory(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejected(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => DocumentStatusEnum::Rejected,
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', '-7 days'),
|
||||
'rejection_reason' => fake()->sentence(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function high(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'priority' => DocumentPriorityEnum::High,
|
||||
]);
|
||||
}
|
||||
|
||||
public function medium(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'priority' => DocumentPriorityEnum::Medium,
|
||||
'processing_deadline' => fake()->dateTimeBetween('now', '+3 days'),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\MediaCollectionEnum;
|
||||
use App\Models\Document;
|
||||
use App\Models\Medium;
|
||||
use App\Models\Report;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MediaAssignment>
|
||||
*/
|
||||
class MediaAssignmentFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$mediableType = fake()->randomElement([Document::class, Report::class]);
|
||||
|
||||
return [
|
||||
'media_id' => Medium::factory(),
|
||||
'mediable_id' => $mediableType::factory(),
|
||||
'mediable_type' => $mediableType,
|
||||
'collection' => fake()->randomElement(MediaCollectionEnum::cases()),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function forDocument(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'mediable_id' => Document::factory(),
|
||||
'mediable_type' => Document::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function forReport(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'mediable_id' => Report::factory(),
|
||||
'mediable_type' => Report::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function primary(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::Primary,
|
||||
]);
|
||||
}
|
||||
|
||||
public function history(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::History,
|
||||
]);
|
||||
}
|
||||
|
||||
public function attachments(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::Attachments,
|
||||
]);
|
||||
}
|
||||
|
||||
public function thumbnails(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::Thumbnails,
|
||||
]);
|
||||
}
|
||||
|
||||
public function documents(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::Documents,
|
||||
]);
|
||||
}
|
||||
|
||||
public function images(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'collection' => MediaCollectionEnum::Images,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\MediaDiskEnum;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Medium>
|
||||
*/
|
||||
class MediumFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$filename = fake()->word() . '.' . fake()->fileExtension();
|
||||
$disk = fake()->randomElement(MediaDiskEnum::cases());
|
||||
$path = 'uploads/' . fake()->date('Y/m/d') . '/' . $filename;
|
||||
|
||||
return [
|
||||
'filename' => $filename,
|
||||
'disk' => $disk,
|
||||
'path' => $path,
|
||||
'size' => fake()->numberBetween(1024, 10485760),
|
||||
'url' => fake()->optional()->url(),
|
||||
'mime_type' => fake()->mimeType(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function public(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'disk' => MediaDiskEnum::Public,
|
||||
'url' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function private(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'disk' => MediaDiskEnum::Private,
|
||||
'url' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function image(): static
|
||||
{
|
||||
$imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
||||
$extension = fake()->randomElement($imageExtensions);
|
||||
$filename = fake()->word() . '.' . $extension;
|
||||
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'filename' => $filename,
|
||||
'mime_type' => 'image/' . $extension,
|
||||
'size' => fake()->numberBetween(102400, 5242880),
|
||||
]);
|
||||
}
|
||||
|
||||
public function document(): static
|
||||
{
|
||||
$docExtensions = ['pdf', 'doc', 'docx', 'txt'];
|
||||
$extension = fake()->randomElement($docExtensions);
|
||||
$filename = fake()->word() . '.' . $extension;
|
||||
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'filename' => $filename,
|
||||
'mime_type' => $extension === 'pdf' ? 'application/pdf' : 'application/msword',
|
||||
'size' => fake()->numberBetween(51200, 10485760),
|
||||
]);
|
||||
}
|
||||
|
||||
public function small(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'size' => fake()->numberBetween(1024, 102400),
|
||||
]);
|
||||
}
|
||||
|
||||
public function large(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'size' => fake()->numberBetween(5242880, 52428800),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\PetTypeEnum;
|
||||
use App\Enums\PetGenderEnum;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Pet>
|
||||
*/
|
||||
class PetFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->firstName(),
|
||||
'type' => fake()->randomElement(PetTypeEnum::cases()),
|
||||
'gender' => fake()->randomElement(PetGenderEnum::cases()),
|
||||
'breed' => fake()->word(),
|
||||
'weight' => fake()->numberBetween(1, 50),
|
||||
'sterilized' => fake()->boolean(),
|
||||
'birthday' => fake()->dateTimeBetween('-15 years', '-1 year'),
|
||||
'owner_id' => User::factory(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function dog(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'type' => PetTypeEnum::Dog,
|
||||
'breed' => fake()->randomElement(['ژرمن شپرد', 'گلدن رتریور', 'لابادور', 'بولداگ', 'پودل']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function cat(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'type' => PetTypeEnum::Cat,
|
||||
'breed' => fake()->randomElement(['پرشین', 'سیامی', 'مین کون', 'رگدال', 'بنگال']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function male(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'gender' => PetGenderEnum::Male,
|
||||
]);
|
||||
}
|
||||
|
||||
public function female(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'gender' => PetGenderEnum::Female,
|
||||
]);
|
||||
}
|
||||
|
||||
public function sterilized(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'sterilized' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ReportStatusEnum;
|
||||
use App\Models\Document;
|
||||
use App\Models\Medium;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Report>
|
||||
*/
|
||||
class ReportFactory extends Factory
|
||||
{
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'document_id' => Document::factory(),
|
||||
'doctor_id' => User::factory(),
|
||||
'medium_id' => fake()->optional()->randomElement(Medium::pluck('id')->toArray()),
|
||||
'status' => fake()->randomElement(ReportStatusEnum::cases()),
|
||||
'body' => fake()->optional()->paragraphs(3, true),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function draft(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::Draft,
|
||||
'body' => fake()->optional()->paragraph(),
|
||||
'submitted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function inProgress(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::InProgress,
|
||||
'body' => fake()->paragraphs(2, true),
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::Completed,
|
||||
'body' => fake()->paragraphs(4, true),
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function reviewed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::Reviewed,
|
||||
'body' => fake()->paragraphs(4, true),
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function approved(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::Approved,
|
||||
'body' => fake()->paragraphs(4, true),
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function rejected(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => ReportStatusEnum::Rejected,
|
||||
'body' => fake()->paragraphs(2, true),
|
||||
'submitted_at' => fake()->dateTimeBetween('-30 days', 'now'),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\UserEnum;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'username' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'phone' => fake()->phoneNumber(),
|
||||
'level' => UserEnum::Supervisor->value,
|
||||
'fullname' => fake()->firstName() . ' ' . fake()->lastName(),
|
||||
'national_code' => fake()->numberBetween(1000000000, 9999999999),
|
||||
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user