Design Your Final Laravel Project
Goal: Build a complete task management application with authentication, CRUD operations, file uploads, and REST API.
| Table | Purpose |
|---|---|
| users | Store user accounts |
| categories | Task categories (Work, Personal, etc.) |
| tasks | Main task data |
| attachments | File uploads for tasks |
// Already created by Laravel Breeze
- id (bigint, PK)
- name (string)
- email (string, unique)
- email_verified_at (timestamp, nullable)
- password (string)
- remember_token (string, nullable)
- created_at, updated_at
// Migration: create_categories_table
- id (bigint, PK)
- name (string) // Work, Personal, Shopping, etc.
- color (string) // #ff0000 for display
- created_at, updated_at
// Migration: create_tasks_table
- id (bigint, PK)
- user_id (bigint, FK → users.id)
- category_id (bigint, FK → categories.id)
- title (string)
- description (text, nullable)
- status (enum: pending, in_progress, completed)
- priority (enum: low, medium, high)
- due_date (date, nullable)
- completed_at (timestamp, nullable)
- created_at, updated_at
// Migration: create_attachments_table
- id (bigint, PK)
- task_id (bigint, FK → tasks.id)
- file_name (string)
- file_path (string)
- file_size (integer) // in bytes
- mime_type (string)
- created_at, updated_at
// ER Diagram Structure
[User] 1----* [Task] *----1 [Category]
|
*
|
[Attachment]
// Relationships:
User.id → Task.user_id
Category.id → Task.category_id
Task.id → Attachment.task_id
// routes/web.php
Route::middleware(['auth'])->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index']);
Route::resource('tasks', TaskController::class);
Route::resource('categories', CategoryController::class);
});
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/register | Register new user | No |
| POST | /api/login | Login and get token | No |
| GET | /api/tasks | Get all user tasks | Yes |
| POST | /api/tasks | Create new task | Yes |
| GET | /api/tasks/{id} | Get single task | Yes |
| PUT | /api/tasks/{id} | Update task | Yes |
| DELETE | /api/tasks/{id} | Delete task | Yes |
# Create project
composer create-project laravel/laravel task-manager
# Navigate to project
cd task-manager
composer require laravel/breeze --dev
php artisan breeze:install blade
npm install && npm run dev
# .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=task_manager
DB_USERNAME=root
DB_PASSWORD=
php artisan migrate
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
# Generate controllers
php artisan make:controller DashboardController
php artisan make:controller TaskController --resource
php artisan make:controller CategoryController --resource
php artisan make:controller Api/AuthController
php artisan make:controller Api/TaskController --api
# Generate models with migrations
php artisan make:model Category -m
php artisan make:model Task -m
php artisan make:model Attachment -m
resources/views/
├── layouts/
│ └── app.blade.php
├── dashboard.blade.php
├── tasks/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ └── show.blade.php
└── categories/
├── index.blade.php
└── create.blade.php
Requirements:
In Day 2, we'll implement: