base commit

This commit is contained in:
Mekan1206
2026-07-30 17:24:40 +05:00
commit a794dacd39
345 changed files with 29597 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\BonusType;
use App\Models\Bonus;
use App\Models\Employee;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Bonus>
*/
class BonusFactory extends Factory
{
protected $model = Bonus::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'employee_id' => Employee::factory(),
'bonus_date' => fake()->dateTimeBetween('-1 year', 'now'),
'bonus_type' => fake()->randomElement(BonusType::cases()),
'amount' => fake()->randomFloat(2, 100, 5000),
'reason' => fake()->optional()->sentence(),
];
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Department;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Department>
*/
class DepartmentFactory extends Factory
{
protected $model = Department::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->unique()->company(),
'code' => strtoupper(fake()->unique()->bothify('??##')),
'description' => fake()->optional()->sentence(),
'is_active' => true,
];
}
public function inactive(): static
{
return $this->state(fn (array $attributes): array => [
'is_active' => false,
]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\DisciplinarySeverity;
use App\Models\DisciplinaryReport;
use App\Models\Employee;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<DisciplinaryReport>
*/
class DisciplinaryReportFactory extends Factory
{
protected $model = DisciplinaryReport::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'employee_id' => Employee::factory(),
'report_date' => fake()->dateTimeBetween('-1 year', 'now'),
'title' => fake()->sentence(4),
'description' => fake()->paragraph(),
'severity' => fake()->randomElement(DisciplinarySeverity::cases()),
'attachment_path' => null,
'created_by' => User::factory(),
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\DocumentType;
use App\Models\Employee;
use App\Models\EmployeeDocument;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<EmployeeDocument>
*/
class EmployeeDocumentFactory extends Factory
{
protected $model = EmployeeDocument::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$type = fake()->randomElement(DocumentType::cases());
return [
'employee_id' => Employee::factory(),
'document_type' => $type,
'title' => $type->label().' - '.fake()->word(),
'file_path' => 'documents/'.fake()->uuid().'.pdf',
'uploaded_at' => fake()->dateTimeBetween('-1 year', 'now'),
];
}
}

View File

@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\EmploymentStatus;
use App\Enums\Gender;
use App\Models\Department;
use App\Models\Employee;
use App\Models\Position;
use App\Models\Shift;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Employee>
*/
class EmployeeFactory extends Factory
{
protected $model = Employee::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$hireDate = fake()->dateTimeBetween('-10 years', '-1 month');
$birthDate = fake()->dateTimeBetween('-55 years', '-20 years');
$employmentStatus = fake()->randomElement(EmploymentStatus::cases());
$gender = fake()->randomElement(Gender::cases());
return [
'employee_number' => 'EMP-'.fake()->unique()->numerify('#####'),
'full_name' => fake()->name($gender === Gender::Female ? 'female' : 'male'),
'national_id' => fake()->optional(0.8)->numerify('##########'),
'gender' => $gender,
'birth_date' => $birthDate,
'phone' => '+993 61 92 92 48',
'address' => fake()->optional()->address(),
'department_id' => Department::factory(),
'position_id' => Position::factory(),
'shift_id' => Shift::factory(),
'employment_status' => $employmentStatus,
'hire_date' => $hireDate,
'termination_date' => $employmentStatus === EmploymentStatus::Terminated
? fake()->dateTimeBetween($hireDate, 'now')
: null,
'notes' => fake()->optional(0.3)->sentence(),
'profile_photo_path' => null,
];
}
public function active(): static
{
return $this->state(fn (array $attributes): array => [
'employment_status' => EmploymentStatus::Active,
'termination_date' => null,
]);
}
public function terminated(): static
{
return $this->state(function (array $attributes): array {
$hireDate = $attributes['hire_date'] ?? fake()->dateTimeBetween('-5 years', '-1 year');
return [
'employment_status' => EmploymentStatus::Terminated,
'termination_date' => fake()->dateTimeBetween($hireDate, 'now'),
];
});
}
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Employee;
use App\Models\Explanation;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Explanation>
*/
class ExplanationFactory extends Factory
{
protected $model = Explanation::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'employee_id' => Employee::factory(),
'explanation_date' => fake()->dateTimeBetween('-1 year', 'now'),
'reason' => fake()->sentence(),
'description' => fake()->paragraph(),
'attachment_path' => null,
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Employee;
use App\Models\Gift;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Gift>
*/
class GiftFactory extends Factory
{
protected $model = Gift::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'employee_id' => Employee::factory(),
'gift_date' => fake()->dateTimeBetween('-1 year', 'now'),
'gift_name' => fake()->words(3, true),
'value' => fake()->randomFloat(2, 50, 1000),
'reason' => fake()->optional()->sentence(),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Position;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Position>
*/
class PositionFactory extends Factory
{
protected $model = Position::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->unique()->jobTitle(),
'description' => fake()->optional()->sentence(),
];
}
}

View File

@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Shift;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Shift>
*/
class ShiftFactory extends Factory
{
protected $model = Shift::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$code = fake()->randomElement(['A', 'B', 'C', 'Night']);
$times = match ($code) {
'A' => ['starts_at' => '06:00:00', 'ends_at' => '14:00:00'],
'B' => ['starts_at' => '14:00:00', 'ends_at' => '22:00:00'],
'C' => ['starts_at' => '22:00:00', 'ends_at' => '06:00:00'],
default => ['starts_at' => '22:00:00', 'ends_at' => '06:00:00'],
};
return [
'name' => match ($code) {
'A' => 'Morning Shift',
'B' => 'Afternoon Shift',
'C' => 'Evening Shift',
default => 'Night Shift',
},
'code' => $code.'-'.fake()->unique()->numerify('###'),
'starts_at' => $times['starts_at'],
'ends_at' => $times['ends_at'],
'description' => fake()->optional()->sentence(),
'is_active' => true,
];
}
public function shiftA(): static
{
return $this->state(fn (array $attributes): array => [
'name' => 'Shift A',
'code' => 'A',
'starts_at' => '06:00:00',
'ends_at' => '14:00:00',
]);
}
public function shiftB(): static
{
return $this->state(fn (array $attributes): array => [
'name' => 'Shift B',
'code' => 'B',
'starts_at' => '14:00:00',
'ends_at' => '22:00:00',
]);
}
public function shiftC(): static
{
return $this->state(fn (array $attributes): array => [
'name' => 'Shift C',
'code' => 'C',
'starts_at' => '22:00:00',
'ends_at' => '06:00:00',
]);
}
public function night(): static
{
return $this->state(fn (array $attributes): array => [
'name' => 'Night Shift',
'code' => 'Night',
'starts_at' => '22:00:00',
'ends_at' => '06:00:00',
]);
}
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Employee;
use App\Models\SickLeave;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SickLeave>
*/
class SickLeaveFactory extends Factory
{
protected $model = SickLeave::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$startDate = fake()->dateTimeBetween('-3 months', 'now');
$days = fake()->numberBetween(1, 10);
$endDate = (clone $startDate)->modify("+{$days} days");
return [
'employee_id' => Employee::factory(),
'start_date' => $startDate,
'end_date' => $endDate,
'days' => $days,
'medical_institution' => fake()->optional()->company().' Hospital',
'reason' => fake()->optional()->sentence(),
'document_path' => null,
];
}
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\ApprovalStatus;
use App\Models\Employee;
use App\Models\UnpaidLeave;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<UnpaidLeave>
*/
class UnpaidLeaveFactory extends Factory
{
protected $model = UnpaidLeave::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$startDate = fake()->dateTimeBetween('-3 months', '+1 month');
$days = fake()->numberBetween(1, 30);
$endDate = (clone $startDate)->modify("+{$days} days");
$status = fake()->randomElement(ApprovalStatus::cases());
return [
'employee_id' => Employee::factory(),
'start_date' => $startDate,
'end_date' => $endDate,
'days' => $days,
'reason' => fake()->optional()->sentence(),
'status' => $status,
'approved_by' => $status === ApprovalStatus::Pending ? null : User::factory(),
'approved_at' => $status === ApprovalStatus::Pending ? null : fake()->dateTimeBetween($startDate, 'now'),
];
}
public function pending(): static
{
return $this->state(fn (array $attributes): array => [
'status' => ApprovalStatus::Pending,
'approved_by' => null,
'approved_at' => null,
]);
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Department;
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 $model = User::class;
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'department_id' => Department::factory(),
];
}
public function unverified(): static
{
return $this->state(fn (array $attributes): array => [
'email_verified_at' => null,
]);
}
public function withoutDepartment(): static
{
return $this->state(fn (array $attributes): array => [
'department_id' => null,
]);
}
}

View File

@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\ApprovalStatus;
use App\Enums\VacationType;
use App\Models\Employee;
use App\Models\User;
use App\Models\Vacation;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Vacation>
*/
class VacationFactory extends Factory
{
protected $model = Vacation::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$startDate = fake()->dateTimeBetween('-6 months', '-1 day');
$days = fake()->numberBetween(1, 14);
$endDate = (clone $startDate)->modify("+{$days} days");
$status = fake()->randomElement(ApprovalStatus::cases());
return [
'employee_id' => Employee::factory(),
'type' => fake()->randomElement(VacationType::cases()),
'start_date' => $startDate,
'end_date' => $endDate,
'return_date' => (clone $endDate)->modify('+1 day'),
'days' => $days,
'status' => $status,
'reason' => fake()->optional()->sentence(),
'attachment_path' => null,
'approved_by' => $status === ApprovalStatus::Pending ? null : User::factory(),
'approved_at' => $status === ApprovalStatus::Pending
? null
: fake()->dateTimeBetween($startDate, 'now'),
];
}
public function pending(): static
{
return $this->state(fn (array $attributes): array => [
'status' => ApprovalStatus::Pending,
'approved_by' => null,
'approved_at' => null,
]);
}
public function approved(): static
{
return $this->state(fn (array $attributes): array => [
'status' => ApprovalStatus::Approved,
'approved_by' => User::factory(),
'approved_at' => now(),
]);
}
}