🎯 Week 20, Day 1: Task Management System - Planning

Design Your Final Laravel Project

📖 Learning Objectives

🎯 Project Overview: Task Management System

Goal: Build a complete task management application with authentication, CRUD operations, file uploads, and REST API.

Core Features:

Technologies Used:

🗄️ Database Schema

Tables Required:

Table Purpose
users Store user accounts
categories Task categories (Work, Personal, etc.)
tasks Main task data
attachments File uploads for tasks

Users Table:

// 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

Categories Table:

// Migration: create_categories_table - id (bigint, PK) - name (string) // Work, Personal, Shopping, etc. - color (string) // #ff0000 for display - created_at, updated_at

Tasks Table:

// 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

Attachments Table:

// 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

📊 Entity Relationship Diagram

Relationships:

  • User → Tasks: One-to-Many (A user has many tasks)
  • Category → Tasks: One-to-Many (A category has many tasks)
  • Task → Attachments: One-to-Many (A task has many attachments)
// 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

🔐 Authentication Flow

User Journey:

  1. Guest: Visit homepage → See login/register links
  2. Register: Fill registration form → Create account → Auto login → Redirect to dashboard
  3. Login: Enter credentials → Authenticate → Redirect to dashboard
  4. Dashboard: View task summary → Create/manage tasks
  5. Logout: Click logout → End session → Redirect to home

Protected Routes:

// routes/web.php Route::middleware(['auth'])->group(function () { Route::get('/dashboard', [DashboardController::class, 'index']); Route::resource('tasks', TaskController::class); Route::resource('categories', CategoryController::class); });

🚀 API Endpoints

Task API Routes:

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

🏗️ Project Setup

Step 1: Create Laravel Project

# Create project composer create-project laravel/laravel task-manager # Navigate to project cd task-manager

Step 2: Install Laravel Breeze

composer require laravel/breeze --dev php artisan breeze:install blade npm install && npm run dev

Step 3: Configure Database

# .env DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=task_manager DB_USERNAME=root DB_PASSWORD=

Step 4: Run Initial Migrations

php artisan migrate

Step 5: Install Laravel Sanctum

composer require laravel/sanctum php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" php artisan migrate

📁 Project Structure Planning

Controllers Needed:

# 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

Models Needed:

# Generate models with migrations php artisan make:model Category -m php artisan make:model Task -m php artisan make:model Attachment -m

Views Structure:

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

✍️ Practice Exercises

Exercise 1: Create ER Diagram

  1. Draw ER diagram on paper or use draw.io
  2. Include all 4 tables
  3. Show relationships with cardinality
  4. Mark primary and foreign keys

Exercise 2: Set Up Project

  1. Create new Laravel project "task-manager"
  2. Install Laravel Breeze
  3. Configure database connection
  4. Run migrations
  5. Test login/register pages

Exercise 3: Generate Resources

  1. Generate all required controllers
  2. Generate all models with migrations
  3. Create views folder structure
  4. Install Laravel Sanctum

🎯 Today's Deliverable

✅ Project Planning Documentation

Requirements:

  • Complete ER diagram (digital or hand-drawn)
  • List of all features to implement
  • Database schema for all tables
  • API endpoint documentation
  • Laravel project set up with Breeze
  • Database created and migrated
  • All controllers and models generated

📚 Summary

🔜 What's Next?

In Day 2, we'll implement: