Skip to main content
Prueba Soporte uses a relational database (MySQL or SQLite) managed entirely through Laravel Eloquent migrations. There are four tables created by the initial migrations: users, password_reset_tokens, sessions, and tasks.

Entity relationship

One user can own many tasks. When a user is deleted, all of their tasks are automatically deleted via the CASCADE constraint on the foreign key.

Table schemas

users table

Created by migration 0001_01_01_000000_create_users_table.php.

tasks table

Created by migration 2024_09_09_123452_create_task.php.
The TaskController@index method filters tasks with Task::where('completed', 0)->get(), so only pending tasks are ever returned to the frontend. Completed tasks remain in the database but are not exposed through the API.

Supporting tables

The users migration also creates two auxiliary tables: password_reset_tokens — Stores one-time tokens for the password reset flow.
sessions — Stores database-backed PHP sessions (used when SESSION_DRIVER=database).

Eloquent models

Task model

Key properties:
  • $table = 'tasks' — explicit table name (matches the default convention but stated explicitly).
  • $guarded = [] — no columns are guarded from mass assignment. All columns can be filled via new Task([...]) or Task::create([...]).
  • user() — defines a belongsTo relationship to User via the user_id foreign key.
Setting $guarded = [] disables all mass-assignment protection. Any column in the tasks table can be filled via a mass-assignment call. Consider switching to an explicit $fillable array (['title', 'description', 'user_id', 'completed']) to restrict what can be set.

User model

Key properties:
  • Extends Authenticatable — provides authentication logic, session management, and password hashing support.
  • $fillable — only name, email, and password can be mass-assigned.
  • $hidden — password and remember_token are excluded from JSON serialization (e.g. in API responses).
  • casts() — email_verified_at is returned as a Carbon datetime object; password is automatically hashed when set.
  • tasks() — defines a hasMany relationship to Task. Calling $user->tasks returns all tasks owned by that user.

Relationship summary

The onDelete('cascade') constraint on tasks.user_id ensures that deleting a user from the users table automatically removes all associated rows from the tasks table at the database level, independently of the Eloquent relationship.