Skip to main content

Overview

The Terminals API allows you to manage radio terminal types and models used in the system. You can create, read, update, and delete terminal type records including their brand, model, usage type, and optional images.

List Terminals

Retrieve a paginated list of terminal types.
GET /terminales

Response

Returns a paginated list of terminals (20 per page).
id
integer
Unique identifier for the terminal type
tipo_uso_id
integer
required
Foreign key reference to the usage type (TipoUso)
marca
string
required
Brand/manufacturer of the terminal
modelo
string
required
Model name or number of the terminal
observaciones
text
Additional notes or observations about the terminal type
imagen
string
File path to the terminal image (stored in images/uploads/)
tipo_uso
object
Associated usage type object with its details

Example Request

curl -X GET "https://your-domain.com/terminales" \
  -H "Cookie: your-session-cookie"

Create Terminal Type

Create a new terminal type with optional image upload.
POST /terminales

Required Permissions

  • crear-terminal

Request Body

tipo_uso
string
required
Usage type for the terminal. Must match an existing uso value in the tipo_uso table (cannot be “Selecciona su uso”).
marca
string
required
Brand or manufacturer name of the terminal
modelo
string
required
Model name or number
observaciones
text
Additional notes or observations about this terminal type
imagen
file
Image file for the terminal. If provided, the file will be uploaded to images/uploads/ with a timestamp prefix.

Example Request

curl -X POST "https://your-domain.com/terminales" \
  -H "Cookie: your-session-cookie" \
  -F "tipo_uso=Móvil" \
  -F "marca=Motorola" \
  -F "modelo=DGP8550e" \
  -F "observaciones=Radio digital con GPS" \
  -F "imagen=@/path/to/terminal-image.jpg"

Response

On success, redirects to /terminales (index page).

Error Responses

result
string
“ERROR” if the operation fails
message
string
Detailed error message from the exception
All create and update operations are wrapped in database transactions. If any error occurs, the transaction is rolled back to maintain data integrity.

Create Form

Retrieve the form for creating a new terminal type.
GET /terminales/create

Required Permissions

  • crear-terminal

Response

Returns a view with available usage types (tipo_uso) for the dropdown.

Edit Terminal Type

Retrieve terminal type details for editing.
GET /terminales/{id}/edit

Required Permissions

  • editar-terminal

Path Parameters

id
integer
required
The ID of the terminal type to edit

Response

Returns a view with the terminal data and available usage types.

Update Terminal Type

Update an existing terminal type.
PUT /terminales/{id}

Required Permissions

  • editar-terminal

Path Parameters

id
integer
required
The ID of the terminal type to update

Request Body

tipo_uso
string
required
Usage type for the terminal (must exist in tipo_uso table)
marca
string
required
Brand or manufacturer name
modelo
string
required
Model name or number
observaciones
text
Additional notes
imagen
file
New image file. If not provided, the existing image is preserved.

Example Request

curl -X PUT "https://your-domain.com/terminales/1" \
  -H "Cookie: your-session-cookie" \
  -F "tipo_uso=Móvil" \
  -F "marca=Motorola" \
  -F "modelo=DGP8550e Plus" \
  -F "observaciones=Radio digital con GPS actualizado" \
  -F "imagen=@/path/to/new-image.jpg"

Response

On success, redirects to /terminales (index page).
When updating, if no new image is provided, the system preserves the existing image path. Only upload a new image if you want to replace the current one.

Delete Terminal Type

Delete a terminal type from the system.
DELETE /terminales/{id}

Required Permissions

  • borrar-terminal

Path Parameters

id
integer
required
The ID of the terminal type to delete

Response

On success, redirects to /terminales (index page).
Be careful when deleting terminal types that are referenced by equipment records. This may cause foreign key constraint violations.

Validation Rules

When creating or updating terminal types, the following validation rules apply:
  • tipo_uso: Required, cannot be “Selecciona su uso”
  • marca: Required string field
  • modelo: Required string field
  • observaciones: Optional text field
  • imagen: Optional file upload

Image Upload

The image upload functionality has the following characteristics:
  • Images are stored in the images/uploads/ directory
  • Uploaded files are prefixed with a Unix timestamp to ensure uniqueness
  • Format: {timestamp}-{original-filename}
  • Example: 1710435200-motorola-dgp8550e.jpg
  • Only uploaded when a file is present in the request

Image Storage Example

if($request->hasFile('imagen')){
    $file = $request->file('imagen');
    $destinationPath = 'images/uploads/';
    $filename = time() . '-' . $file->getClientOriginalName();
    $uploadSuccess = $request->file('imagen')->move($destinationPath, $filename);
    $terminal->imagen = $destinationPath . $filename;
}

Error Codes

422
Validation Error
Validation failed. Common errors include:
  • Missing required fields (marca, modelo, tipo_uso)
  • Invalid tipo_uso selection
403
Forbidden
You don’t have the required permission to perform this action.
500
Server Error
Database transaction failed or file upload error. Returns JSON with error details:
{
  "result": "ERROR",
  "message": "Detailed error message"
}

Relationships

Terminal types have the following relationships:
  • tipo_uso (belongs to): Associated usage type that categorizes the terminal
  • equipos (has many): Equipment records that use this terminal type

Controller Source

You can find the implementation in:
  • Controller: app/Http/Controllers/TipoTerminalController.php
  • Model: app/Models/TipoTerminal.php
  • Table: tipo_terminales

Build docs developers (and LLMs) love