ultimatepos/Modules/Maintenance/Support/MaintenanceSchema.php

75 lines
1.9 KiB
PHP

<?php
namespace Modules\Maintenance\Support;
use Illuminate\Support\Facades\Schema;
class MaintenanceSchema
{
public static function hasTable(string $table): bool
{
return Schema::hasTable($table);
}
/**
* @return array<int, string>
*/
public static function equipmentShowRelations(): array
{
$with = [
'category',
'project',
'customer',
'fixedAsset',
];
if (self::hasTable('maintenance_production_lines')) {
$with[] = 'productionLine.project';
}
if (self::hasTable('maintenance_equipment_parts')) {
$with[] = 'equipmentParts';
if (self::hasTable('maintenance_spare_parts')) {
$with[] = 'equipmentParts.sparePart';
}
if (self::hasTable('maintenance_part_catalogs')) {
$with[] = 'equipmentParts.partCatalog';
}
}
if (self::hasTable('maintenance_asset_documents')) {
$with[] = 'documents';
}
if (self::hasTable('maintenance_inspection_visits')) {
$with[] = 'inspectionVisits';
}
if (self::hasTable('maintenance_service_records')) {
$with[] = 'serviceRecords';
}
if (self::hasTable('maintenance_part_replacements')) {
$with[] = 'partReplacements.equipmentPart';
}
if (self::hasTable('maintenance_preventive_schedules')) {
$with[] = 'preventiveSchedules';
}
if (self::hasTable('maintenance_overhauls')) {
$with[] = 'overhauls';
}
if (self::hasTable('maintenance_work_orders')) {
$with[] = 'workOrders';
}
if (self::hasTable('maintenance_history_entries')) {
$with[] = 'historyEntries.performer';
}
return $with;
}
}