Skip to main content
API Endpoints Not Yet Implemented: The current version of GIMA does not expose RESTful CRUD endpoints for assets. This page documents the underlying data model for reference. Asset management is performed through the Eloquent ORM in the application layer.

Asset Model Structure

The Activo model represents physical assets in the system with the following fields:

Fields

id
integer
Unique asset identifier (auto-generated)
articulo_id
integer
required
Foreign key to articulos table - defines what type of item this asset is
ubicacion_id
integer
required
Foreign key to ubicaciones table - physical location of the asset
estado
EstadoActivo
required
Asset operational status enum: operativo, mantenimiento, fuera_servicio, baja
valor
float
Monetary value of the asset for financial tracking
created_at
timestamp
Record creation timestamp
updated_at
timestamp
Record last update timestamp

Model Relationships

The Activo model has the following relationships defined:
App/Models/Activo.php
// Belongs to an article definition
public function articulo(): BelongsTo
{
    return $this->belongsTo(Articulos::class, 'articulo_id');
}

// Belongs to a location
public function ubicacion(): BelongsTo
{
    return $this->belongsTo(Ubicacion::class, 'ubicacion_id');
}

// Has many maintenance calendar entries
public function calendarioMantenimientos(): HasMany
{
    return $this->hasMany(CalendarioMantenimiento::class, 'activo_id');
}

// Has many maintenance records
public function mantenimientos(): HasMany
{
    return $this->hasMany(Mantenimiento::class, 'activo_id');
}

// Has many failure reports
public function reportes(): HasMany
{
    return $this->hasMany(Reporte::class, 'activo_id');
}

Usage Examples

Querying Assets

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

// Get all operational assets
$operationalAssets = Activo::where('estado', EstadoActivo::OPERATIVO)->get();

// Get assets with their article info
$assetsWithArticles = Activo::with('articulo')->get();

// Find asset by ID with all relationships
$asset = Activo::with([
    'articulo',
    'ubicacion',
    'mantenimientos',
    'reportes',
    'calendarioMantenimientos'
])->findOrFail($id);

// Filter by location
$buildingAssets = Activo::whereHas('ubicacion', function($query) {
    $query->where('edificio', 'Edificio A');
})->get();

Creating Assets

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

// Create a new asset
$activo = Activo::create([
    'articulo_id' => 5,
    'ubicacion_id' => 3,
    'estado' => EstadoActivo::OPERATIVO,
    'valor' => 15000.00
]);

Updating Assets

// Update asset status
$activo = Activo::findOrFail($id);
$activo->estado = EstadoActivo::MANTENIMIENTO;
$activo->save();

// Move asset to new location
$activo->update([
    'ubicacion_id' => $newLocationId
]);

Accessing Relationships

// Get asset with maintenance history
$activo = Activo::findOrFail($id);

// Access related article
$marca = $activo->articulo->marca;
$modelo = $activo->articulo->modelo;

// Get all maintenance records
$historial = $activo->mantenimientos;

// Count pending reports
$reportesAbiertos = $activo->reportes()
    ->where('estado', EstadoReporte::ABIERTO)
    ->count();

State Transitions

Assets follow a lifecycle with state transitions: See the Asset Management guide for detailed lifecycle information.

Future API Endpoints

Future versions of GIMA will expose RESTful endpoints for asset operations:
  • GET /api/activos - List assets
  • GET /api/activos/{id} - Get single asset
  • POST /api/activos - Create asset
  • PUT /api/activos/{id} - Update asset
  • DELETE /api/activos/{id} - Delete asset
  • PATCH /api/activos/{id}/estado - Update asset status

Database Model

Complete Activo model documentation

Asset Management Concept

Asset lifecycle and management strategies

Maintenance API

Maintenance operations documentation

Reports API

Failure reporting documentation

Build docs developers (and LLMs) love