Skip to main content

Overview

GIMA uses PHP 8.1+ backed enums to provide type-safe, predictable values for various status fields and categories throughout the system. All enums are string-backed and include a label() method for human-readable display values.

EstadoActivo

Defines the operational state of assets in the system. Namespace: App\Enums\EstadoActivo Type: string

Cases

OPERATIVO
string
default:"operativo"
Asset is operational and in active use.Label: “Operativo”
MANTENIMiENTO
string
default:"mantenimiento"
Asset is currently undergoing maintenance.Label: “En mantenimiento”
FUERA_SERVICIO
string
default:"fuera_servicio"
Asset is out of service but not permanently decommissioned.Label: “Fuera de Servicio”
BAJA
string
default:"baja"
Asset has been permanently decommissioned.Label: “Dado de baja”

Usage Example

use App\Enums\EstadoActivo;
use App\Models\Activo;

// Set asset state
$activo = Activo::find(1);
$activo->estado = EstadoActivo::OPERATIVO;
$activo->save();

// Get label
echo $activo->estado->label(); // "Operativo"

// Compare states
if ($activo->estado === EstadoActivo::MANTENIMiENTO) {
    echo "Asset is under maintenance";
}

// Get all cases
$estados = EstadoActivo::cases();

TipoMantenimiento

Defines the type of maintenance operation. Namespace: App\Enums\TipoMantenimiento Type: string

Cases

CORRECTIVO
string
default:"correctivo"
Corrective maintenance - fixing issues and problems.Label: “Correctivo”
PREDICTIVO
string
default:"predictivo"
Predictive maintenance - based on condition monitoring and predictions.Label: “Predictivo”
PREVENTIVO
string
default:"preventivo"
Preventive maintenance - scheduled regular maintenance.Label: “Preventivo”

Usage Example

use App\Enums\TipoMantenimiento;
use App\Models\Mantenimiento;

$mantenimiento = Mantenimiento::create([
    'activo_id' => 1,
    'tipo' => TipoMantenimiento::PREVENTIVO->value,
    // ... other fields
]);

// Check maintenance type
if ($mantenimiento->tipo === 'preventivo') {
    echo "This is scheduled preventive maintenance";
}

EstadoMantenimiento

Defines the current status of a maintenance operation. Namespace: App\Enums\EstadoMantenimiento Type: string

Cases

PENDIENTE
string
default:"pendiente"
Maintenance is pending and not yet started.Label: “Pendiente”
EN_PROCESO
string
default:"en_proceso"
Maintenance is currently in progress.Label: “En Proceso”
COMPLETADO
string
default:"completado"
Maintenance has been completed.Label: “Completado”
CANCELADO
string
default:"cancelado"
Maintenance has been cancelled.Label: “Cancelado”

Usage Example

use App\Enums\EstadoMantenimiento;

$mantenimiento = Mantenimiento::find(1);
$mantenimiento->estado = EstadoMantenimiento::EN_PROCESO->value;
$mantenimiento->save();

// Query by status
$completados = Mantenimiento::where('estado', EstadoMantenimiento::COMPLETADO->value)->get();

NivelPrioridad

Defines priority levels for reports and tasks. Namespace: App\Enums\NivelPrioridad Type: string

Cases

ALTA
string
default:"alta"
High priority - urgent attention required.Label: “Alta”
MEDIA
string
default:"media"
Medium priority - normal processing.Label: “Media”
BAJA
string
default:"baja"
Low priority - non-urgent.Label: “Baja”

Usage Example

use App\Enums\NivelPrioridad;
use App\Models\Reporte;

$reporte = Reporte::create([
    'usuario_id' => 5,
    'activo_id' => 1,
    'descripcion' => 'Equipment malfunction',
    'prioridad' => NivelPrioridad::ALTA->value,
]);

// Get high priority reports
$urgentes = Reporte::where('prioridad', NivelPrioridad::ALTA->value)->get();

EstadoReporte

Defines the lifecycle status of issue reports. Namespace: App\Enums\EstadoReporte Type: string

Cases

ABIERTO
string
default:"abierto"
Report has been opened and not yet processed.Label: “Abierto”
ASIGNADO
string
default:"asignado"
Report has been assigned to a technician.Label: “Asignado”
EN_PROCESO
string
default:"en_progreso"
Report is being worked on.Label: “En Proceso”Note: The database value is en_progreso (with underscore).
RESUELTO
string
default:"resuelto"
Issue has been resolved.Label: “Resuelto”
CERRADO
string
default:"cerrado"
Report has been closed.Label: “Cerrado”

Usage Example

use App\Enums\EstadoReporte;

$reporte = Reporte::find(1);
$reporte->estado = EstadoReporte::ASIGNADO->value;
$reporte->save();

// Get open reports
$abiertos = Reporte::where('estado', EstadoReporte::ABIERTO->value)->get();

UserStatusEnum

Defines the account status for system users. Namespace: App\Enums\UserStatusEnum Type: string

Cases

ACTIVO
string
default:"activo"
User account is active and can access the system.Label: “Activo”
INACTIVO
string
default:"inactivo"
User account is inactive.Label: “Inactivo”
SUSPENDIDO
string
default:"suspendido"
User account has been temporarily suspended.Label: “Suspendido Temporalmente”

Usage Example

use App\Enums\UserStatusEnum;
use App\Models\User;

$user = User::find(1);
$user->estado = UserStatusEnum::ACTIVO;
$user->save();

// Check status
if ($user->estado === UserStatusEnum::SUSPENDIDO) {
    echo "User is suspended: " . $user->estado->label();
}

// Get all active users
$activeUsers = User::where('estado', UserStatusEnum::ACTIVO->value)->get();

TipoArticulo

Defines the type/category of articles (asset definitions). Namespace: App\Enums\TipoArticulo Type: string

Cases

MOBILIARIO
string
default:"mobiliario"
Furniture and fixtures.Label: “mobiliario”
EQUIPO
string
default:"equipo"
Equipment and machinery.Label: “equipo”

Usage Example

use App\Enums\TipoArticulo;
use App\Models\Articulos;

$articulo = Articulos::create([
    'modelo' => 'DeskPro 3000',
    'marca' => 'OfficeMax',
    'tipo' => TipoArticulo::MOBILIARIO->value,
]);

TipoDireccion

Defines hierarchical location types for the addressing system. Namespace: App\Enums\TipoDireccion Type: string

Cases

PAIS
string
default:"pais"
Country level.Label: “País”
ESTADO
string
default:"estado"
State/Province level.Label: “Estado”
CIUDAD
string
default:"ciudad"
City level.Label: “Ciudad”
SECTOR
string
default:"sector"
Sector/District level.Label: “Sector”
CALLE
string
default:"calle"
Street level.Label: “Calle”
CAMPUS
string
default:"campus"
Campus level.Label: “Campus”
EDIFICIO
string
default:"edificio"
Building level.Label: “Edificio”
PISO
string
default:"piso"
Floor level.Label: “Piso”
SALON
string
default:"salon"
Room/Classroom level.Label: “Salón”

Usage Example

use App\Enums\TipoDireccion;
use App\Models\Direccion;

// Create hierarchical addresses
$campus = Direccion::create([
    'nombre' => 'Campus Norte',
    'tipo' => TipoDireccion::CAMPUS->value,
]);

$edificio = Direccion::create([
    'nombre' => 'Edificio A',
    'tipo' => TipoDireccion::EDIFICIO->value,
    'direccion_padre_id' => $campus->id,
]);

TipoMaterial

Defines the type of documentation/material for articles. Namespace: App\Enums\TipoMaterial Type: string

Cases

DATASHEET
string
default:"datasheet"
Technical datasheet.Label: “datasheet”
MANUAL
string
default:"manual"
User or maintenance manual.Label: “manual”
ENLACE
string
default:"enlace"
Web link/URL to external resource.Label: “enlace”

Usage Example

use App\Enums\TipoMaterial;
use App\Models\MaterialArticulos;

$material = MaterialArticulos::create([
    'articulo_id' => 1,
    'tipo' => TipoMaterial::MANUAL->value,
    'nombre' => 'Manual de Usuario',
    'ruta_archivo' => '/docs/manual.pdf',
]);

General Usage Patterns

Getting All Enum Cases

use App\Enums\EstadoActivo;

// Get all cases as array
$estados = EstadoActivo::cases();

foreach ($estados as $estado) {
    echo $estado->value;   // "operativo", "mantenimiento", etc.
    echo $estado->label(); // "Operativo", "En mantenimiento", etc.
}

Using Enums in Forms

use App\Enums\NivelPrioridad;

// Generate select options
$prioridades = collect(NivelPrioridad::cases())->map(function($prioridad) {
    return [
        'value' => $prioridad->value,
        'label' => $prioridad->label(),
    ];
});

Validation with Enums

use Illuminate\Validation\Rule;
use App\Enums\EstadoActivo;

$request->validate([
    'estado' => ['required', Rule::in(array_column(EstadoActivo::cases(), 'value'))],
]);

Type Safety

use App\Enums\TipoMantenimiento;

function procesarMantenimiento(TipoMantenimiento $tipo) {
    match($tipo) {
        TipoMantenimiento::PREVENTIVO => $this->preventivo(),
        TipoMantenimiento::CORRECTIVO => $this->correctivo(),
        TipoMantenimiento::PREDICTIVO => $this->predictivo(),
    };
}

processarMantenimiento(TipoMantenimiento::PREVENTIVO);

Best Practices

  1. Always use enum cases in code instead of raw strings for type safety
  2. Use .value when storing to database or comparing with database values
  3. Use .label() for display to users in UI
  4. Leverage match expressions for exhaustive handling of enum cases
  5. Use Rule::in() for validation to ensure only valid enum values are accepted

Build docs developers (and LLMs) love