170 lines
8.4 KiB
PHP
170 lines
8.4 KiB
PHP
<?php
|
||
|
||
namespace Database\Seeders;
|
||
|
||
use App\Models\Currency;
|
||
use App\Models\Project;
|
||
use App\Models\Tenant;
|
||
use App\Models\User;
|
||
use Illuminate\Database\Seeder;
|
||
|
||
class ProjectSeeder extends Seeder
|
||
{
|
||
/**
|
||
* Run the database seeds.
|
||
*
|
||
* Creates realistic construction project data for both tenants:
|
||
* - Tenant 1 (Sepideh): 5 Persian-named projects (IRR currency)
|
||
* - Tenant 2 (Global): 3 English-named projects (USD currency)
|
||
*/
|
||
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();
|
||
|
||
$tenant1Manager = User::where('email', 'manager@sepideh.ir')->firstOrFail();
|
||
$tenant1Admin = User::where('email', 'admin@sepideh.ir')->firstOrFail();
|
||
$tenant2Admin = User::where('email', 'admin@global.com')->firstOrFail();
|
||
|
||
// ─────────────────────────────────────────────
|
||
// Tenant 1 — Sepideh (Persian construction projects)
|
||
// ─────────────────────────────────────────────
|
||
|
||
$persianProjects = [
|
||
[
|
||
'tenant_id' => $tenant1->id,
|
||
'name' => 'ساختمان مسکونی گلستان',
|
||
'code' => 'SPD-1403-001',
|
||
'description' => 'ساخت مجتمع مسکونی ۱۲ طبقه شامل ۹۶ واحد در منطقه ۲ تهران',
|
||
'status' => 'in_progress',
|
||
'start_date' => '2024-04-20',
|
||
'end_date' => '2025-10-20',
|
||
'progress' => 45,
|
||
'budget' => 850000000000, // 850 billion IRR
|
||
'default_currency_id' => $irr->id,
|
||
'budget_usd' => 20238095.24,
|
||
'manager_id' => $tenant1Manager->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant1->id,
|
||
'name' => 'پل عابر سپید',
|
||
'code' => 'SPD-1403-002',
|
||
'description' => 'ساخت پل عابر پیاده با طول ۴۵ متر و عرض ۵ متر در بزرگراه همت',
|
||
'status' => 'planning',
|
||
'start_date' => '2024-09-01',
|
||
'end_date' => '2025-06-30',
|
||
'progress' => 10,
|
||
'budget' => 120000000000, // 120 billion IRR
|
||
'default_currency_id' => $irr->id,
|
||
'budget_usd' => 2857142.86,
|
||
'manager_id' => $tenant1Admin->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant1->id,
|
||
'name' => 'مجتمع تجاری مروارید',
|
||
'code' => 'SPD-1403-003',
|
||
'description' => 'ساخت مجتمع تجاری ۸ طبقه شامل ۱۲۰ واحد تجاری و پارکینگ ۳ طبقه',
|
||
'status' => 'in_progress',
|
||
'start_date' => '2024-01-15',
|
||
'end_date' => '2025-12-31',
|
||
'progress' => 62,
|
||
'budget' => 1200000000000, // 1.2 trillion IRR
|
||
'default_currency_id' => $irr->id,
|
||
'budget_usd' => 28571428.57,
|
||
'manager_id' => $tenant1Manager->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant1->id,
|
||
'name' => 'استخر و سونا سلامت',
|
||
'code' => 'SPD-1403-004',
|
||
'description' => 'ساخت مجموعه ورزشی شامل استخر المپیک، سونا خشک و بخار و سالن بدنسازی',
|
||
'status' => 'completed',
|
||
'start_date' => '2023-06-01',
|
||
'end_date' => '2024-05-30',
|
||
'progress' => 100,
|
||
'budget' => 350000000000, // 350 billion IRR
|
||
'default_currency_id' => $irr->id,
|
||
'budget_usd' => 8333333.33,
|
||
'manager_id' => $tenant1Admin->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant1->id,
|
||
'name' => 'بازسازی بیمارستان شفا',
|
||
'code' => 'SPD-1403-005',
|
||
'description' => 'بازسازی و نوسازی بخشهای داخلی بیمارستان شفا شامل اورژانس، ICU و بخش جراحی',
|
||
'status' => 'on_hold',
|
||
'start_date' => '2024-03-01',
|
||
'end_date' => '2025-03-01',
|
||
'progress' => 25,
|
||
'budget' => 500000000000, // 500 billion IRR
|
||
'default_currency_id' => $irr->id,
|
||
'budget_usd' => 11904761.90,
|
||
'manager_id' => $tenant1Manager->id,
|
||
],
|
||
];
|
||
|
||
foreach ($persianProjects as $projectData) {
|
||
Project::create($projectData);
|
||
}
|
||
|
||
// ─────────────────────────────────────────────
|
||
// Tenant 2 — Global (English construction projects)
|
||
// ─────────────────────────────────────────────
|
||
|
||
$englishProjects = [
|
||
[
|
||
'tenant_id' => $tenant2->id,
|
||
'name' => 'Riverside Tower',
|
||
'code' => 'GLO-2024-001',
|
||
'description' => 'Construction of a 20-story mixed-use tower with retail, office, and residential spaces along the waterfront',
|
||
'status' => 'in_progress',
|
||
'start_date' => '2024-02-01',
|
||
'end_date' => '2026-06-30',
|
||
'progress' => 35,
|
||
'budget' => 45000000, // 45M USD
|
||
'default_currency_id' => $usd->id,
|
||
'budget_usd' => 45000000.00,
|
||
'manager_id' => $tenant2Admin->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant2->id,
|
||
'name' => 'Industrial Warehouse Complex',
|
||
'code' => 'GLO-2024-002',
|
||
'description' => 'Building a 50,000 sqm warehouse complex with loading docks and logistics center',
|
||
'status' => 'planning',
|
||
'start_date' => '2024-08-01',
|
||
'end_date' => '2025-04-30',
|
||
'progress' => 5,
|
||
'budget' => 12000000, // 12M USD
|
||
'default_currency_id' => $usd->id,
|
||
'budget_usd' => 12000000.00,
|
||
'manager_id' => $tenant2Admin->id,
|
||
],
|
||
[
|
||
'tenant_id' => $tenant2->id,
|
||
'name' => 'Greenfield School Campus',
|
||
'code' => 'GLO-2024-003',
|
||
'description' => 'Construction of a modern school campus with three buildings, sports facilities, and parking area',
|
||
'status' => 'completed',
|
||
'start_date' => '2023-05-01',
|
||
'end_date' => '2024-07-15',
|
||
'progress' => 100,
|
||
'budget' => 8500000, // 8.5M USD
|
||
'default_currency_id' => $usd->id,
|
||
'budget_usd' => 8500000.00,
|
||
'manager_id' => $tenant2Admin->id,
|
||
],
|
||
];
|
||
|
||
foreach ($englishProjects as $projectData) {
|
||
Project::create($projectData);
|
||
}
|
||
|
||
$total = count($persianProjects) + count($englishProjects);
|
||
$this->command->info("Projects seeded: {$total} records created.");
|
||
}
|
||
}
|