This is a Laravel 6-based Task Management API that allows users to create, update, delete, and manage tasks. Each task can be assigned to a user, and comments can be added. The task owner will receive an email notification when new comments are added.
✅ User Authentication (Register, Login, Logout)
✅ Task Management (CRUD Operations)
✅ Assign Tasks to Users
✅ Comment System on Tasks
✅ Email Notification on New Comments (Using Queues)
✅ Secure API with Token Authentication
git clone https://github.com/your-repository.git
cd your-repository
composer install
Rename .env.example
to .env
and update database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password
php artisan key:generate
php artisan migrate
php artisan passport:install
Then update config/auth.php
file:
'guards' => [
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
php artisan db:seed
php artisan serve
All requests require a Bearer Token.
POST /api/register
Body (JSON):
{
"name": "John Doe",
"email": "john@example.com",
"password": "password",
"password_confirmation": "password"
}
POST /api/login
Body (JSON):
{
"email": "john@example.com",
"password": "password"
}
Response: { "token": "ACCESS_TOKEN" }
POST /api/logout
Headers:
Authorization: Bearer ACCESS_TOKEN
🔹 CREATE TASK:
POST /api/tasks
Headers: Authorization + JSON
Body:
{
"title": "New Task",
"description": "Task details",
"due_date": "2025-03-20"
}
🔹 GET ALL TASKS:
GET /api/tasks
Headers: Authorization
🔹 GET SINGLE TASK:
GET /api/tasks/{task_id}
Headers: Authorization
🔹 UPDATE TASK:
PUT /api/tasks/{task_id}
Headers: Authorization + JSON
Body:
{
"title": "Updated Task",
"description": "Updated details",
"status": "in-progress",
"due_date": "2025-03-25"
}
🔹 DELETE TASK:
DELETE /api/tasks/{task_id}
Headers: Authorization
🔹 ADD COMMENT TO TASK:
POST /api/tasks/{task_id}/comments
Headers: Authorization + JSON
Body:
{
"comment": "This is a comment"
}
🔹 GET COMMENTS FOR TASK:
GET /api/tasks/{task_id}/comments
Headers: Authorization
🔹 UPDATE COMMENT:
PUT /api/tasks/{task_id}/comments/{comment_id}
Headers: Authorization + JSON
Body:
{
"comment": "Updated comment"
}
🔹 DELETE COMMENT:
DELETE /api/tasks/{task_id}/comments/{comment_id}
Headers: Authorization
When a new comment is added to a task, the task owner will receive an email notification.
Run the queue worker: php artisan queue:work
To test the API using Postman:
- Open Postman.
- Click Import.
- Select the Postman collection file:
task_manager.postman_collection.json
- Set Base URL as: http://127.0.0.1:8000/api
🔸 ISSUE: 404 Not Found
for API Endpoints
✔ Ensure you are using http://127.0.0.1:8000/api/{endpoint}
✔ Run php artisan route:list
to verify available routes
🔸 ISSUE: Passport Not Working
✔ Run php artisan passport:install
✔ Add Passport::routes();
in AuthServiceProvider.php
✔ Clear cache with php artisan cache:clear
🔸 ISSUE: Queue Not Processing Emails
✔ Start the queue worker with php artisan queue:work
✔ Check mail settings in .env
Your Task Management API is now fully functional! 🚀
If you encounter any issues, feel free to ask! 😊