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

248 lines
12 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\Task;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Database\Seeder;
class TaskSeeder extends Seeder
{
/**
* Run the database seeds.
*
* Creates 15 sample tasks distributed across projects with
* various statuses and priorities to reflect realistic project activity.
*
* Distribution:
* - 10 tasks for tenant 1 projects (Sepideh)
* - 5 tasks for tenant 2 projects (Global)
*/
public function run(): void
{
$tenant1 = Tenant::where('slug', 'sepideh')->firstOrFail();
$tenant2 = Tenant::where('slug', 'global')->firstOrFail();
$tenant1Projects = $tenant1->projects()->orderBy('id')->get();
$tenant2Projects = $tenant2->projects()->orderBy('id')->get();
$manager = User::where('email', 'manager@sepideh.ir')->firstOrFail();
$admin1 = User::where('email', 'admin@sepideh.ir')->firstOrFail();
$admin2 = User::where('email', 'admin@global.com')->firstOrFail();
// ─────────────────────────────────────────────
// Tenant 1 — Sepideh Tasks
// ─────────────────────────────────────────────
$tenant1Tasks = [
// Project: ساختمان مسکونی گلستان
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[0]->id,
'title' => 'تأمین مصالح مرحله اسکلت',
'description' => 'خرید و تحویل میلگرد، سیمان و آجر برای اسکلت طبقات ۵ تا ۸',
'status' => 'in_progress',
'priority' => 'high',
'assignee_id' => $manager->id,
'due_date' => '2024-08-15',
'progress' => 60,
'estimated_hours' => 120.00,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[0]->id,
'title' => 'نصب قالب‌بندی طبقه ۶',
'description' => 'قالب‌بندی ستون‌ها و دال طبقه ششم با نظارت مهندس ناظر',
'status' => 'todo',
'priority' => 'medium',
'assignee_id' => $admin1->id,
'due_date' => '2024-09-01',
'progress' => 0,
'estimated_hours' => 80.00,
],
// Project: پل عابر سپید
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[1]->id,
'title' => 'مطالعات ژئوتکنیک',
'description' => 'انجاد گمانه‌های ژئوتکنیک و تهیه گزارش خاک‌شناسی محوطه پروژه',
'status' => 'in_progress',
'priority' => 'urgent',
'assignee_id' => $manager->id,
'due_date' => '2024-07-30',
'progress' => 80,
'estimated_hours' => 200.00,
],
// Project: مجتمع تجاری مروارید
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[2]->id,
'title' => 'نصب سیستم تهویه مطبوع',
'description' => 'نصب چیلر، داکت‌ها و ایرواشر طبقات تجاری',
'status' => 'in_progress',
'priority' => 'high',
'assignee_id' => $manager->id,
'due_date' => '2024-11-30',
'progress' => 35,
'estimated_hours' => 480.00,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[2]->id,
'title' => 'تأسیسات برقی فاز ۲',
'description' => 'سیم‌کشی تابلوهای برق اصلی و پنل‌های کنترلی طبقات ۴ تا ۸',
'status' => 'review',
'priority' => 'medium',
'assignee_id' => $admin1->id,
'due_date' => '2024-08-20',
'progress' => 90,
'estimated_hours' => 160.00,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[2]->id,
'title' => 'نازک‌کاری دیوارهای داخلی',
'description' => 'گچ‌کاری و نازک‌کاری دیوارهای داخلی واحد‌های تجاری طبقات ۱ تا ۳',
'status' => 'todo',
'priority' => 'low',
'assignee_id' => null,
'due_date' => '2025-01-15',
'progress' => 0,
'estimated_hours' => 320.00,
],
// Project: استخر و سونا سلامت
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[3]->id,
'title' => 'تست فشار لوله‌کشی',
'description' => 'تست هیدرواستاتیک لوله‌های آب سرد و گرم و سیستم فاضلاب',
'status' => 'done',
'priority' => 'high',
'assignee_id' => $admin1->id,
'due_date' => '2024-04-15',
'progress' => 100,
'estimated_hours' => 40.00,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[3]->id,
'title' => 'تحویل نهایی به کارفرما',
'description' => 'آماده‌سازی اسناد تحویل، لیست عیوب و رفع آنها و تحویل رسمی',
'status' => 'done',
'priority' => 'medium',
'assignee_id' => $manager->id,
'due_date' => '2024-05-30',
'progress' => 100,
'estimated_hours' => 24.00,
],
// Project: بازسازی بیمارستان شفا
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[4]->id,
'title' => 'تخریب دیوارهای داخلی بخش اورژانس',
'description' => 'تخریب و حمل مصالح دیوارهای غیرسازه‌ای بخش اورژانس فعلی',
'status' => 'todo',
'priority' => 'urgent',
'assignee_id' => $manager->id,
'due_date' => '2024-09-15',
'progress' => 0,
'estimated_hours' => 96.00,
],
[
'tenant_id' => $tenant1->id,
'project_id' => $tenant1Projects[4]->id,
'title' => 'تهیه نقشه‌های اجرایی',
'description' => 'تکمیل نقشه‌های اجرایی معماری، تأسیسات و برق برای بخش ICU',
'status' => 'in_progress',
'priority' => 'high',
'assignee_id' => $admin1->id,
'due_date' => '2024-08-10',
'progress' => 50,
'estimated_hours' => 160.00,
],
];
foreach ($tenant1Tasks as $taskData) {
Task::create($taskData);
}
// ─────────────────────────────────────────────
// Tenant 2 — Global Tasks
// ─────────────────────────────────────────────
$tenant2Tasks = [
// Project: Riverside Tower
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[0]->id,
'title' => 'Foundation Pouring — Phase 2',
'description' => 'Complete concrete pouring for the tower foundation section B including reinforcement inspection',
'status' => 'in_progress',
'priority' => 'urgent',
'assignee_id' => $admin2->id,
'due_date' => '2024-08-30',
'progress' => 70,
'estimated_hours' => 240.00,
],
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[0]->id,
'title' => 'Structural Steel Erection — Floors 5-8',
'description' => 'Erect and weld structural steel frames for floors 5 through 8 of the tower',
'status' => 'todo',
'priority' => 'high',
'assignee_id' => $admin2->id,
'due_date' => '2024-11-15',
'progress' => 0,
'estimated_hours' => 360.00,
],
// Project: Industrial Warehouse Complex
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[1]->id,
'title' => 'Site Survey & Soil Testing',
'description' => 'Conduct topographic survey and soil bearing capacity tests across the 50,000 sqm site',
'status' => 'in_progress',
'priority' => 'high',
'assignee_id' => $admin2->id,
'due_date' => '2024-09-15',
'progress' => 45,
'estimated_hours' => 120.00,
],
// Project: Greenfield School Campus
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[2]->id,
'title' => 'Final Inspection & Handover',
'description' => 'Complete final building inspection, fire safety certification, and handover to the school board',
'status' => 'done',
'priority' => 'medium',
'assignee_id' => $admin2->id,
'due_date' => '2024-07-10',
'progress' => 100,
'estimated_hours' => 40.00,
],
[
'tenant_id' => $tenant2->id,
'project_id' => $tenant2Projects[2]->id,
'title' => 'Landscaping & Parking Lot Completion',
'description' => 'Final grading, asphalt paving for parking area, and installation of outdoor lighting and signage',
'status' => 'review',
'priority' => 'low',
'assignee_id' => null,
'due_date' => '2024-07-15',
'progress' => 95,
'estimated_hours' => 80.00,
],
];
foreach ($tenant2Tasks as $taskData) {
Task::create($taskData);
}
$total = count($tenant1Tasks) + count($tenant2Tasks);
$this->command->info("Tasks seeded: {$total} records created.");
}
}