Mega Creative has two resource controllers: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.
EstudianteController and CarreraController. Both extend the base Controller class located at app/Http/Controllers/Controller.php, which in turn extends Laravel’s Illuminate\Routing\Controller and includes the AuthorizesRequests, DispatchesJobs, and ValidatesRequests traits. Each controller implements all seven standard Laravel resourceful actions: index, create, store, show, edit, update, and destroy.
Route Registration
Both controllers are registered together usingRoute::resources() in routes/web.php, which generates a full set of named routes for each resource:
EstudianteController
Located atapp/Http/Controllers/EstudianteController.php, this controller manages the full lifecycle of student records. It imports all seven models at the top of the file to support the create and edit forms that require full lookup-table data.
index()
Fetches every student record from the database and passes the collection to the listing view.
- Route:
GET /estudiantes - View:
resources/views/estudiantes/index.blade.php - Data: Full
$estudiantescollection
create()
Loads all six lookup model collections so the creation form can populate every dropdown (gender, program, status, country, state, city).
- Route:
GET /estudiantes/create - View:
resources/views/estudiantes/create.blade.php
store(Request $request)
Validates all incoming form data, constructs a new Estudiante instance, persists it, and redirects to the index with a success flash message.
Validation rules:
sexo field → sexo_id foreign key), saves the record, and issues a redirect:
- Route:
POST /estudiantes
show($id)
Retrieves a single student by primary key and returns the detail view.
- Route:
GET /estudiantes/{id} - View:
resources/views/estudiantes/show.blade.php
edit($id)
Loads the target student plus all six lookup collections so the edit form is pre-populated and all dropdowns are available.
- Route:
GET /estudiantes/{id}/edit - View:
resources/views/estudiantes/edit.blade.php
update(Request $request, $id)
Applies the same validation rules as store(), then finds the existing student, assigns each field individually on the model instance, and saves.
- Route:
PUT/PATCH /estudiantes/{id}
destroy($id)
Finds the student by ID, deletes the record, and redirects to the index with a confirmation message.
- Route:
DELETE /estudiantes/{id}
CarreraController
Located atapp/Http/Controllers/CarreraController.php, this controller manages academic programs. It is simpler than EstudianteController because a Carrera only has one relationship (to Status) and three fillable fields.
index()
Retrieves all programs and returns the listing view.
- Route:
GET /carreras - View:
resources/views/carreras/index.blade.php
create()
Loads all statuses for the dropdown on the creation form.
- Route:
GET /carreras/create - View:
resources/views/carreras/create.blade.php
store(Request $request)
Validates the three required fields, creates a new Carrera, saves it, and redirects.
Validation rules:
- Route:
POST /carreras
show($id)
Finds a program by ID and renders the detail view.
- Route:
GET /carreras/{id} - View:
resources/views/carreras/show.blade.php
edit($id)
Retrieves the target program and all statuses for the edit form.
- Route:
GET /carreras/{id}/edit - View:
resources/views/carreras/edit.blade.php
update(Request $request, $id)
Validates, locates the program, assigns each field directly, and saves.
- Route:
PUT/PATCH /carreras/{id}
destroy($id)
Deletes a program by ID and redirects with a confirmation message.
- Route:
DELETE /carreras/{id}
Flash Messages
Both controllers use Laravel’s session flash pattern to communicate the outcome of write operations to the user. After a successfulstore, update, or destroy, the controller chains ->with('key', 'message') onto the redirect response:
session()->get('success') and render it inside a Bootstrap alert:
Validation errors are handled separately by Laravel’s
ValidatesRequests trait (inherited through the base Controller). When validation fails, the framework automatically redirects back to the form and populates the $errors bag, which the views display using @if ($errors->any()).