Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/keving5726/megacreative/llms.txt

Use this file to discover all available pages before exploring further.

The Programs (Carreras) module manages the catalog of academic programs available for student enrollment. Each program has a unique name, a short description, and an active/inactive status. Programs are lightweight — the carreras table has no timestamp columns — but they are central to the registry because every student must be linked to one program via carrera_id.

Program Fields

The carreras table is defined in 2019_09_09_171012_create_carreras_table.php. All three fields are required and validated before a record is saved.
FieldTypeDescription
nombrestring, max 100, uniqueProgram name — must be unique across all programs
descripcionstring, max 180Short description of the program
status_idFK → statusesActive status — Habilitado or Inhabilitado
The carreras table uses tinyIncrements for its primary key and has no timestamps columns (public $timestamps = false in the model). The nombre column carries a UNIQUE constraint at the database level.

Routes

Programs share the Route::resources() declaration in routes/web.php alongside students, giving CarreraController a full set of RESTful routes.
MethodPathController MethodPurpose
GET/carrerasindexList all academic programs
GET/carreras/createcreateDisplay the create form
POST/carrerasstorePersist a new program
GET/carreras/{id}showDisplay a single program detail
GET/carreras/{id}/editeditDisplay the edit form
PUT/PATCH/carreras/{id}updateUpdate an existing program
DELETE/carreras/{id}destroyDelete a program

Validation Rules

CarreraController@store() and CarreraController@update() both apply the same three rules before writing to the database.
$request->validate([
    'nombre'      => 'required|max:100',
    'descripcion' => 'required|max:180',
    'status'      => 'required',
]);
The create and edit forms load the full list of statuses so users can select from a dropdown:
// CarreraController@create  /  CarreraController@edit
$statuses = Status::all();

return view('carreras.create', compact('statuses'));

Relationship to Students

Deleting a program permanently deletes every student enrolled in it. The carrera_id foreign key on estudiantes is declared with ->onDelete('cascade'), so the database engine will remove all child rows automatically when a program is deleted. This action cannot be undone from the application interface.
The cascade is defined in the estudiantes migration:
$table->foreign('carrera_id')
      ->references('id')
      ->on('carreras')
      ->onDelete('cascade');
The Carrera model exposes a single Eloquent relationship back to the statuses table:
// app/Carrera.php

class Carrera extends Model
{
    protected $table    = 'carreras';
    protected $fillable = ['nombre', 'descripcion', 'status_id'];
    public    $timestamps = false;

    public function status()
    {
        return $this->hasOne('App\Status', 'id', 'status_id');
    }
}
In Blade views you can display the resolved status label like this:
{{ $carrera->status->status }}   {{-- outputs "Habilitado" or "Inhabilitado" --}}
Before deleting a program, consider first reassigning enrolled students to another program or setting the program’s status to Inhabilitado. This marks it inactive without triggering the cascade delete.

Build docs developers (and LLMs) love