tasks table.
Creating a task with an assignment
The task form inTaskList.vue includes a field for the assignee’s email:
newTask object in component data holds the three fields:
The
user field expects a valid email address belonging to a registered user in the system. Entering a name, username, or any other identifier will cause the task creation to fail.How the controller resolves the user
When the form is submitted, the Vuex store POSTs to/tasks. TaskController@store validates all three fields and then queries for the user by email:
What happens if the user is not found
If no user with the provided email exists, the controller callsredirect()->back()->withErrors(...). The validation error is returned on the user field with the message “User not found.” The task is not saved.
Database schema
Thetasks table stores the assignment as a user_id foreign key that references the users table:
user_id is a required (non-nullable) column — every task in the database has exactly one assigned user. The onDelete('cascade') constraint means that if a user account is deleted, all of their assigned tasks are also permanently removed.
Eloquent relationships
The assignment is represented in both models with inverse Eloquent relationships.Task belongs to a User:
User has many Task records:
$user->tasks, or traverse to the owner of a task with $task->user.
Displaying the assigned user
In the current implementation, the task list template displaystask.user directly: