vernova/database/seeders/EmployeeSeeder.php
2026-07-26 19:58:27 +03:30

298 lines
14 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Database\Seeders;
use App\Models\Currency;
use App\Models\Employee;
use App\Models\Tenant;
use Illuminate\Database\Seeder;
class EmployeeSeeder extends Seeder
{
/**
* Run the database seeds.
*
* Creates sample employee records for both tenants:
* - Tenant 1 (Sepideh): 10 employees with Persian names (IRR salaries)
* - Tenant 2 (Global): 5 employees with English names (USD salaries)
*/
public function run(): void
{
$tenant1 = Tenant::where('slug', 'sepideh')->firstOrFail();
$tenant2 = Tenant::where('slug', 'global')->firstOrFail();
$irr = Currency::where('code', 'IRR')->firstOrFail();
$usd = Currency::where('code', 'USD')->firstOrFail();
$tenant1Projects = $tenant1->projects()->orderBy('id')->get();
$tenant2Projects = $tenant2->projects()->orderBy('id')->get();
// ─────────────────────────────────────────────
// Tenant 1 — Sepideh Employees (Persian)
// ─────────────────────────────────────────────
$tenant1Employees = [
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[0]->id, // ساختمان مسکونی گلستان
'national_code' => '0012345678',
'first_name' => 'حسین',
'last_name' => 'محمدی',
'phone' => '09121234567',
'job_title' => 'مهندس عمران',
'contract_type' => 'permanent',
'hire_date' => '2022-03-01',
'status' => 'active',
'base_salary' => 85000000, // 85M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-1234-5678',
'notes' => null,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[0]->id,
'national_code' => '0023456789',
'first_name' => 'رضا',
'last_name' => 'کریمی',
'phone' => '09132345678',
'job_title' => 'کارگر ساختمانی',
'contract_type' => 'temporary',
'hire_date' => '2024-04-01',
'status' => 'active',
'base_salary' => 45000000, // 45M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-2345-6789',
'notes' => null,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[1]->id, // پل عابر سپید
'national_code' => '0034567890',
'first_name' => 'مهدی',
'last_name' => 'حسینی',
'phone' => '09143456789',
'job_title' => 'مهندس راه و ترابری',
'contract_type' => 'permanent',
'hire_date' => '2023-06-15',
'status' => 'active',
'base_salary' => 92000000, // 92M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-3456-7890',
'notes' => null,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[2]->id, // مجتمع تجاری مروارید
'national_code' => '0045678901',
'first_name' => 'فاطمه',
'last_name' => 'احمدی',
'phone' => '09154567890',
'job_title' => 'حسابدار',
'contract_type' => 'permanent',
'hire_date' => '2022-09-01',
'status' => 'active',
'base_salary' => 78000000, // 78M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-4567-8901',
'notes' => null,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[2]->id,
'national_code' => '0056789012',
'first_name' => 'امیر',
'last_name' => 'نجفی',
'phone' => '09165678901',
'job_title' => 'تاسیساتکار',
'contract_type' => 'contractor',
'hire_date' => '2024-01-10',
'status' => 'active',
'base_salary' => 65000000, // 65M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-5678-9012',
'notes' => 'پیمانکار تاسیسات مکانیکی',
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[3]->id, // استخر و سونا سلامت
'national_code' => '0067890123',
'first_name' => 'سعید',
'last_name' => 'موسوی',
'phone' => '09176789012',
'job_title' => 'برقکار',
'contract_type' => 'temporary',
'hire_date' => '2023-08-20',
'status' => 'terminated',
'termination_date' => '2024-05-30',
'base_salary' => 55000000, // 55M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-6789-0123',
'notes' => 'پروژه به اتمام رسیده — تسویه شده',
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[4]->id, // بازسازی بیمارستان شفا
'national_code' => '0078901234',
'first_name' => 'زهرا',
'last_name' => 'صادقی',
'phone' => '09187890123',
'job_title' => 'معمار',
'contract_type' => 'permanent',
'hire_date' => '2023-01-15',
'status' => 'on_leave',
'base_salary' => 88000000, // 88M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-7890-1234',
'notes' => 'مرخصی استعلاجی از ۱۴۰۳/۰۴/۰۱ تا ۱۴۰۳/۰۶/۳۱',
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[4]->id,
'national_code' => '0089012345',
'first_name' => 'محمد',
'last_name' => 'جعفری',
'phone' => '09198901234',
'job_title' => 'نجار',
'contract_type' => 'contractor',
'hire_date' => '2024-03-01',
'status' => 'active',
'base_salary' => 50000000, // 50M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-8901-2345',
'notes' => 'پیمانکار کارهای چوب و دکوراسیون',
],
[
'tenant_id' => $tenant1->id,
'project_id' => null,
'national_code' => '0090123456',
'first_name' => 'علی',
'last_name' => 'عباسی',
'phone' => '09209012345',
'job_title' => 'راننده',
'contract_type' => 'temporary',
'hire_date' => '2024-02-15',
'status' => 'active',
'base_salary' => 40000000, // 40M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-9012-3456',
'notes' => 'راننده کامیون حمل مصالح',
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[0]->id,
'national_code' => '0101234567',
'first_name' => 'مریم',
'last_name' => 'رحیمی',
'phone' => '09210123456',
'job_title' => 'مسئول انبار',
'contract_type' => 'permanent',
'hire_date' => '2023-11-01',
'status' => 'active',
'base_salary' => 52000000, // 52M IRR
'currency_id' => $irr->id,
'bank_account' => '6037-9975-0123-4567',
'notes' => null,
],
];
foreach ($tenant1Employees as $empData) {
Employee::create($empData);
}
// ─────────────────────────────────────────────
// Tenant 2 — Global Employees (English)
// ─────────────────────────────────────────────
$tenant2Employees = [
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[0]->id, // Riverside Tower
'national_code' => '1000000001',
'first_name' => 'David',
'last_name' => 'Johnson',
'phone' => '+1-555-0101',
'job_title' => 'Civil Engineer',
'contract_type' => 'permanent',
'hire_date' => '2023-01-15',
'status' => 'active',
'base_salary' => 8500, // 8,500 USD
'currency_id' => $usd->id,
'bank_account' => 'US12-3456-7890-1234',
'notes' => null,
],
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[0]->id,
'national_code' => '1000000002',
'first_name' => 'Sarah',
'last_name' => 'Williams',
'phone' => '+1-555-0102',
'job_title' => 'Project Coordinator',
'contract_type' => 'permanent',
'hire_date' => '2023-06-01',
'status' => 'active',
'base_salary' => 6200,
'currency_id' => $usd->id,
'bank_account' => 'US12-3456-7890-5678',
'notes' => null,
],
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[1]->id, // Industrial Warehouse
'national_code' => '1000000003',
'first_name' => 'Michael',
'last_name' => 'Brown',
'phone' => '+1-555-0103',
'job_title' => 'Steel Erector',
'contract_type' => 'contractor',
'hire_date' => '2024-03-10',
'status' => 'active',
'base_salary' => 5500,
'currency_id' => $usd->id,
'bank_account' => 'US12-3456-7890-9012',
'notes' => 'Subcontractor — structural steelwork',
],
[
'tenant_id' => $tenant2->id,
'project_id' => null,
'national_code' => '1000000004',
'first_name' => 'Emily',
'last_name' => 'Davis',
'phone' => '+1-555-0104',
'job_title' => 'Accountant',
'contract_type' => 'permanent',
'hire_date' => '2022-09-15',
'status' => 'active',
'base_salary' => 5800,
'currency_id' => $usd->id,
'bank_account' => 'US12-3456-7890-3456',
'notes' => null,
],
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[2]->id, // Greenfield School
'national_code' => '1000000005',
'first_name' => 'Robert',
'last_name' => 'Taylor',
'phone' => '+1-555-0105',
'job_title' => 'Electrician',
'contract_type' => 'temporary',
'hire_date' => '2024-01-20',
'status' => 'terminated',
'termination_date' => '2024-07-15',
'base_salary' => 4500,
'currency_id' => $usd->id,
'bank_account' => 'US12-3456-7890-7890',
'notes' => 'Project completed — contract ended',
],
];
foreach ($tenant2Employees as $empData) {
Employee::create($empData);
}
$total = count($tenant1Employees) + count($tenant2Employees);
$this->command->info("Employees seeded: {$total} records created.");
}
}