The problem
Most real apps are "a list of things that belong to a person". Building one properly teaches the patterns every job uses.
What you will learn
- Add sign in with a Laravel starter kit
- Create, edit and complete tasks
- Stop users from seeing each other's tasks
- Write feature tests that prove it
What you will build
A Laravel app where people sign up, sign in and manage their own tasks: add a task, mark it done, edit it and delete it. Each person sees only their own tasks, and feature tests prove it. This is the kind of "list of things that belongs to a person" that most real apps are built on.
This project belongs to the Practical software development path. Before you start, finish Your first Laravel route, Build a REST API and Hash passwords properly.

This project is where many separate lessons become one working app. Take it one step at a time and commit after every step.
What you will practise
| Skill | Where |
|---|---|
| Authentication (sign up, sign in) | Step 1, with a Laravel starter kit |
| Relationships between tables | Step 2: a user has many tasks |
| Controllers and resource routes | Step 3 |
| Validation | Step 3 |
| Authorisation (who may change what) | Step 4, with a policy |
| Feature tests | Steps 5 and 6 |
Step 1: Create the project with sign in built in
Do not build authentication from scratch: it is easy to get wrong, and Laravel's official starter kits do it well, including hashed passwords, sessions, password resets and limits on repeated sign-in attempts. In Laravel 13 you choose a starter kit when you create the app, with the Laravel installer.
Install the installer once (skip this if laravel --version already prints a version):
composer global require laravel/installer
Then create the app in your workspace. This project gets its own folder and its own Git repository, next to laravel-app:
cd ~/ewoi-learning laravel new task-tracker
The installer asks questions. Choose:
| Question | Choose | Why |
|---|---|---|
| Starter kit | Livewire | Its pages are Blade, the same templates you already know |
| Authentication | Laravel's built-in authentication | Everything stays on your computer; no outside account needed |
| Testing framework | Pest or PHPUnit | Either works: the tests in this project are PHPUnit classes, and Pest runs them too |
| Database | SQLite | The whole database is one file, database/database.sqlite, so there is nothing else to install |
Run npm install and build |
Yes | Builds the CSS and JavaScript the sign-in pages use |
| Anything else (teams, extra tools) | The default | You can add these later |
If the installer says laravel: command not found, Composer's global bin folder is not on your PATH yet: search for "Composer global bin PATH" in the Composer documentation, follow it, and open a new terminal.
Start the app:
cd task-tracker composer run dev
composer run dev starts the web server and the asset builder together (press Ctrl+C to stop). Open http://localhost:8000, register an account and sign in. You land on the dashboard.
Save this starting point. Run git status first: if it says not a git repository, run git init, then:
git add . git commit -m "Start the task tracker from the Livewire starter kit"
Ask your AI assistant
I created a Laravel 13 app with the Livewire starter kit. Explain, in simple words, what the kit added for sign in: which routes, which files handle registration, and where the password is hashed. Do not suggest building it myself.
Step 2: The tasks table and model
php artisan make:model Task -m
In the new migration (its name ends in create_tasks_table.php):
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('title', 200);
$table->text('notes')->nullable();
$table->timestamp('done_at')->nullable();
$table->timestamps();
});
| Column | Meaning |
|---|---|
foreignId('user_id')->constrained() |
Each task belongs to one user; the database refuses a task for a user that does not exist |
cascadeOnDelete() |
Deleting a user deletes their tasks too |
done_at |
Empty means not done; a time means when it was finished. One column answers both "is it done?" and "when?" |
Replace everything in app/Models/Task.php with:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Task extends Model
{
protected $fillable = ['title', 'notes', 'done_at'];
protected function casts(): array
{
return ['done_at' => 'datetime'];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
Notice user_id is not fillable: the app sets it from the signed-in user, so nobody can create a task for someone else by sending a different user_id.
In app/Models/User.php, add the other side. Add this line with the other use lines at the top:
use Illuminate\Database\Eloquent\Relations\HasMany;
and this method inside the class, just before its last }:
public function tasks(): HasMany
{
return $this->hasMany(Task::class);
}
(Your User.php came from the starter kit, so leave everything else in it as it is.) Create the table and commit:
php artisan migrate git add . git commit -m "Add the tasks table and model"
migrate should list your create_tasks_table migration followed by DONE.
Step 3: Routes, controller and validation
php artisan make:controller TaskController --resource
In routes/web.php, add this use line at the top with the others:
use App\Http\Controllers\TaskController;
and this group above the require line at the bottom, so only signed-in users with a confirmed email reach the task pages:
Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('tasks', TaskController::class)->only(['index', 'store', 'edit', 'update', 'destroy']);
});
Route::resource creates the standard routes for a "resource" (a kind of thing, here tasks) in one line. only([...]) keeps the five this app uses: the add form lives on the list page, so it needs no separate create page, and a task has no show page. Run php artisan route:list --path=tasks to see them: five lines, named tasks.index, tasks.store, tasks.edit, tasks.update and tasks.destroy.
Replace everything in app/Http/Controllers/TaskController.php with:
<?php
namespace App\Http\Controllers;
use App\Models\Task;
use Illuminate\Http\Request;
class TaskController extends Controller
{
public function index(Request $request)
{
return view('tasks.index', [
'tasks' => $request->user()->tasks()->latest()->paginate(20),
]);
}
public function store(Request $request)
{
$data = $request->validate([
'title' => ['required', 'string', 'max:200'],
'notes' => ['nullable', 'string', 'max:2000'],
]);
$request->user()->tasks()->create($data);
return redirect()->route('tasks.index')->with('status', 'Task added.');
}
public function edit(Task $task)
{
return view('tasks.edit', ['task' => $task]);
}
public function update(Request $request, Task $task)
{
$data = $request->validate([
'title' => ['required', 'string', 'max:200'],
'notes' => ['nullable', 'string', 'max:2000'],
]);
$task->update($data);
return redirect()->route('tasks.index')->with('status', 'Task saved.');
}
public function destroy(Task $task)
{
$task->delete();
return redirect()->route('tasks.index')->with('status', 'Task deleted.');
}
}
$request->user()->tasks() is the safe starting point: it only ever reads or creates tasks for the signed-in user. Notice that edit, update and destroy do not check who owns the task yet. That is a real security hole, and Step 4 closes it.
Now the pages. They are plain Blade views with their own small layout, so they work whichever starter kit you chose. Create three files in a new folder, resources/views/tasks/:
layout.blade.php: the page frame (title, a link back to the dashboard, the "Task added." message).index.blade.php: the add form and the list, each task with Edit and Delete.edit.blade.php: the edit form.
Copy them from milestone-02-tasks-crud/resources/views/tasks/ in https://github.com/ewoibuilds/task-tracker-laravel and read them line by line. Two habits to notice: every form has @csrf (Laravel's protection against forged form posts), and every value is printed with {{ }}, which escapes it so a task titled <script> shows as text, never runs. Forms can only send GET or POST, so the edit and delete forms add @method('PUT') and @method('DELETE') to tell Laravel which route they mean.
Open http://localhost:8000/tasks, add a task, edit it and delete it. Then commit:
git add . git commit -m "List, add, edit and delete tasks"
Step 4: Authorisation: nobody touches someone else's task
Here is a classic security bug. The edit address is /tasks/5/edit. What if a signed-in user changes 5 to 6, someone else's task? Without a check, they can read and change it. Laravel's policies stop this:
php artisan make:policy TaskPolicy --model=Task
Replace everything in app/Policies/TaskPolicy.php with only what you need:
<?php
namespace App\Policies;
use App\Models\Task;
use App\Models\User;
class TaskPolicy
{
public function update(User $user, Task $task): bool
{
return $task->user_id === $user->id;
}
public function delete(User $user, Task $task): bool
{
return $task->user_id === $user->id;
}
}
Laravel finds this policy by itself, because it is named after the Task model and sits in app/Policies. Now use it. In the controller, add use Illuminate\Support\Facades\Gate; with the other use lines, and make this the first line of edit and update:
Gate::authorize('update', $task);
and this the first line of destroy:
Gate::authorize('delete', $task);
If the check fails, Laravel replies 403 Forbidden and none of your code below it runs. (Older tutorials write $this->authorize(...). Since Laravel 11 the base controller no longer includes that helper, so Gate::authorize is the way that works out of the box.)
Test it by hand: register a second account in a private browser window, then open /tasks/1/edit (a task of your first account). You should see a 403 page. Commit:
git add . git commit -m "Only the owner can edit or delete a task"

This bug, changing an ID in the address to reach someone else's data, is one of the most common security holes on the web. Always ask: "what if someone changes the number?"
Step 5: Tests that prove it
Laravel includes testing tools. Create a feature test:
php artisan make:test TaskTest --phpunit
--phpunit asks for a test class, the style used here, even if you chose Pest (Pest runs these classes too). Replace the test_example method in tests/Feature/TaskTest.php with tests for the important promises:
public function test_guests_are_sent_to_sign_in(): void
{
$this->get('/tasks')->assertRedirect('/login');
}
public function test_a_user_can_add_a_task(): void
{
$user = User::factory()->create();
$this->actingAs($user)->post('/tasks', ['title' => 'Learn policies'])->assertRedirect('/tasks');
$this->assertDatabaseHas('tasks', ['title' => 'Learn policies', 'user_id' => $user->id]);
}
public function test_nobody_can_edit_someone_elses_task(): void
{
$owner = User::factory()->create();
$task = $owner->tasks()->create(['title' => 'Private']);
$this->actingAs(User::factory()->create())
->put("/tasks/{$task->id}", ['title' => 'Hacked'])
->assertForbidden();
$this->assertSame('Private', $task->fresh()->title);
}
Before you run them, two more lines. The file already imports RefreshDatabase at the top; add use App\Models\User; next to it, and make this the first line inside the class:
use RefreshDatabase;
RefreshDatabase gives every test a clean, empty database, so tests never depend on each other. Now run php artisan test. Every test should pass, and the summary ends with passed. If test_nobody_can_edit_someone_elses_task fails with a 200 or 302 instead of 403, the Gate::authorize line is missing from update. Commit:
git add . git commit -m "Prove the task promises with feature tests"
Step 6: Mark tasks as done
Add one route inside the same auth group in routes/web.php:
Route::patch('tasks/{task}/done', [TaskController::class, 'toggle'])->name('tasks.toggle');
And one method in the controller:
public function toggle(Task $task)
{
Gate::authorize('update', $task);
$task->update(['done_at' => $task->done_at ? null : now()]);
return redirect()->route('tasks.index');
}
It flips the task: not done becomes done now, done becomes not done. Add the button next to each task in index.blade.php and a line through done tasks; the finished view is in milestone-04-tests-and-done in the repo. Copy that milestone's tests/Feature/TaskTest.php too: it adds two tests for the button, including one proving nobody can tick someone else's task. Run php artisan test, then commit:
git add . git commit -m "Mark tasks as done"
Step 7: Publish
- Write a README: what it does, a screenshot, how to run it, how to run the tests, and what you would add next.
- Create an empty repository on GitHub, connect it with
git remote add origin ..., thengit push -u origin main(the Your first commit lesson covers it). Deploy it when you are ready (see Why your first deploy fails).
Stuck at any step? The repo https://github.com/ewoibuilds/task-tracker-laravel has one folder per milestone with the finished files and an acceptance test for each, so you can compare your work or start again from the milestone before.
Ideas to go further
- Due dates and a filter for "due this week".
- Search by title.
- An API for the same tasks, protected with tokens, so a mobile app could use it.
Recap
- Use the starter kit for authentication; do not reinvent it.
- Commit after every step, so you can always go back to a working version.
- Start every query from
$request->user()->tasks(). - Keep
user_idout of$fillable; set it from the signed-in user. - Policies answer "may this user change this task?", and tests prove the answer.
Want a code review of your task tracker? Book a one-to-one session.


