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 Students (Estudiantes) module is the core of Mega Creative. Every student record stores personal information, enrollment data, and geographic location — all linked to shared lookup tables via foreign keys. The module is backed by a full resourceful controller (EstudianteController) that handles listing, creating, showing, editing, updating, and deleting records.

Student Fields

The estudiantes table is defined in 2019_09_09_171016_create_estudiantes_table.php. Every column below is required; none accept null values.
FieldTypeDescription
nombresstring, max 100Student’s first name(s)
apellidosstring, max 100Student’s last name(s)
sexo_idFK → sexosSex — Masculino or Femenino
fecha_de_nacimientodateDate of birth
emailstring, max 100, uniqueEmail address (must be unique across all records)
carrera_idFK → carrerasEnrolled academic program
status_idFK → statusesEnrollment status — Habilitado or Inhabilitado
pais_idFK → paisesCountry of residence
estado_idFK → estadosState or province of residence
ciudad_idFK → ciudadesCity of residence
The email column has a UNIQUE constraint enforced at the database level ($table->unique('email')). Attempting to save a duplicate email will raise a database integrity exception even if server-side validation passes.

Routes

Both estudiantes and carreras are registered together using Laravel’s Route::resources() helper in routes/web.php, which generates the full set of RESTful routes automatically.
MethodPathController MethodPurpose
GET/estudiantesindexList all student records
GET/estudiantes/createcreateDisplay the create form
POST/estudiantesstorePersist a new student record
GET/estudiantes/{id}showDisplay a single student detail
GET/estudiantes/{id}/editeditDisplay the edit form
PUT/PATCH/estudiantes/{id}updateUpdate an existing student record
DELETE/estudiantes/{id}destroyDelete a student record

Validation Rules

Both store() and update() run the same validation rules via $request->validate(). All ten fields are required; nombres, apellidos, and email are additionally capped at their respective max lengths.
$request->validate([
    'nombres'              => 'required|max:100',
    'apellidos'            => 'required|max:100',
    'sexo'                 => 'required',
    'fecha_de_nacimiento'  => 'required',
    'email'                => 'required|max:100',
    'carrera'              => 'required',
    'status'               => 'required',
    'pais'                 => 'required',
    'estado'               => 'required',
    'ciudad'               => 'required',
]);
Laravel’s built-in validation redirects the user back to the form and flashes error messages automatically. The create.blade.php and edit.blade.php views already render an alert-danger block that loops over $errors->all().

Creating a Student

1

Navigate to the create form

Go to GET /estudiantes/create. The EstudianteController@create method fetches all six lookup collections before rendering the view:
$sexos    = Sexo::all();
$carreras = Carrera::all();
$statuses = Status::all();
$paises   = Pais::all();
$estados  = Estado::all();
$ciudades = Ciudad::all();
All six variables are passed to estudiantes.create via compact().
2

Fill in the text fields

Enter the student’s Nombres (first names) and Apellidos (last names), each capped at 100 characters. Provide a valid Email address — it must be unique across the whole system. Pick a Fecha de Nacimiento using the date picker.
3

Choose from the dropdowns

Four dropdown selects are populated from lookup tables:
  • Sexo — rendered from $sexos, displays the tipo column (Masculino / Femenino), posts the record id.
  • Carrera — rendered from $carreras, displays the nombre column.
  • Status — rendered from $statuses, displays the status column (Habilitado / Inhabilitado).
  • Pais / Estado / Ciudad — three chained geographic dropdowns rendered from $paises, $estados, and $ciudades respectively, each displaying the nombre column.
4

Submit the form

The form posts to POST /estudiantes. On success the controller saves the record and redirects to /estudiantes with a flash message: "Estudiante creado con exito!".

Relationships

The Estudiante model declares six hasOne relationships — one for every foreign key column. Each resolves the associated lookup record by matching the local *_id column to the primary key of the related table.
// app/Estudiante.php

class Estudiante extends Model
{
    protected $table = 'estudiantes';
    protected $guarded = ['id, created_at, updated_at'];

    public function sexo()
    {
        return $this->hasOne('App\Sexo', 'id', 'sexo_id');
    }

    public function carrera()
    {
        return $this->hasOne('App\Carrera', 'id', 'carrera_id');
    }

    public function status()
    {
        return $this->hasOne('App\Status', 'id', 'status_id');
    }

    public function pais()
    {
        return $this->hasOne('App\Pais', 'id', 'pais_id');
    }

    public function estado()
    {
        return $this->hasOne('App\Estado', 'id', 'estado_id');
    }

    public function ciudad()
    {
        return $this->hasOne('App\Ciudad', 'id', 'ciudad_id');
    }
}
In Blade views you can access related data via dynamic properties, for example:
{{ $estudiante->carrera->nombre }}
{{ $estudiante->sexo->tipo }}
{{ $estudiante->status->status }}
{{ $estudiante->pais->nombre }}

Build docs developers (and LLMs) love