Overview
TheTeacherController handles teacher record management including listing, creation, and deletion. All operations require admin privileges.
File Location: app/controllers/TeacherController.php
Dependencies:
TeachermodelAuthhelper
Methods
index()
Displays list of all teachers. Authorization: Admin only Behavior:- Retrieves all teacher records from database
- Renders teacher listing view
app/views/teachers/index.php
create()
Displays teacher creation form and handles teacher registration. Authorization: Admin onlyTeacher’s full name (POST request)
Teacher’s email address (POST request)
Teacher’s password (POST request)
- GET request: Displays creation form
- POST request: Creates new teacher and redirects
- GET: Renders creation form at
app/views/teachers/create.php - POST: Redirects to
/teachers
delete()
Deletes a teacher record. Authorization: Admin onlyTeacher ID to delete (from GET query parameter)
- Validates admin authorization
- Deletes teacher from database
- Redirects to teacher listing
/teachers
Usage Examples
Creating a Teacher
Deleting a Teacher
Security Notes
- All methods enforce admin-only access via
Auth::admin() - Passwords are processed by the Teacher model (should be hashed)
- No session or authentication data returned in responses