A modular Laravel REST API for managing user tasks with authentication, real-time notifications, and auto-generated API docs.
- 🔐 Auth via Laravel Sanctum
- 📋 Task CRUD (create, list, update, delete)
- ⚙️ Filtering by status or due date
- 🔔 Realtime Notifications (Pusher)
- 🗃️ Stored Notifications in DB
- 🧪 API Documentation using Scribe
- 🧰 Queue Support (database / sync)
| Layer | Technology |
|---|---|
| Framework | Laravel 12 |
| Auth | Laravel Sanctum |
| Database | MySQL |
| Realtime | Pusher / Laravel WebSockets |
| Queue | Database |
| Docs | Scribe |
| Tests | Pest / PHPUnit |
app/
├── Http/
│ ├── Controllers/Api/
│ │ ├── AuthController.php
│ │ ├── TaskController.php
│ │ └── NotificationController.php
│ ├── Requests/Task/
│ │ ├── TaskStoreRequest.php
│ │ └── TaskUpdateRequest.php
│ └── Resources/TaskResource.php
├── Models/Task.php
├── Notifications/TaskStatusChanged.php
├── Policies/TaskPolicy.php
routes/
├── api.php
└── channels.php
Register
POST /api/register
{
"name": "Amr",
"email": "amr@example.com",
"password": "password",
"password_confirmation": "password"
}Login
POST /api/login
{
"email": "amr@example.com",
"password": "password"
}Use returned token:
Authorization: Bearer {token}
All endpoints require auth:sanctum.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks |
List tasks (filters: status, due_from, due_to) |
| POST | /api/tasks |
Create a new task |
| GET | /api/tasks/{id} |
Show task |
| PUT | /api/tasks/{id} |
Update task |
| DELETE | /api/tasks/{id} |
Soft delete |
| PATCH | /api/tasks/{id}/status |
Update status & trigger notification |
Example:
{
"title": "Finish backend module",
"description": "Complete Laravel evaluation",
"due_date": "2025-10-25"
}Stored in DB + broadcasted in real time.
TaskStatusChanged notification uses:
public function via($notifiable)
{
return ['database', 'broadcast'];
}Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/notifications |
List user notifications |
| POST | /api/notifications/{id}/read |
Mark as read |
| POST | /api/notifications/read-all |
Mark all as read |
routes/channels.php
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});Register with Sanctum auth:
Broadcast::routes(['middleware' => ['auth:sanctum']]);
require base_path('routes/channels.php');BROADCAST_CONNECTION=pusher
PUSHER_APP_ID=xxxxx
PUSHER_APP_KEY=xxxxx
PUSHER_APP_SECRET=xxxxx
PUSHER_APP_CLUSTER=eu
QUEUE_CONNECTION=databaseAfter updates:
php artisan config:clear && php artisan cache:clearUse sync for local:
QUEUE_CONNECTION=syncRun queues:
php artisan queue:workRun tests:
php artisan test- Ensure
BROADCAST_CONNECTION=pusher. - Install dependency:
composer require pusher/pusher-php-server. - Clear cache:
php artisan config:clear. - Run worker if queued:
php artisan queue:work. - Test events in Pusher console.
# 1️⃣ Clone the project
git clone https://github.com/yourusername/task-management-api.git
# 2️⃣ Navigate into the project
cd task-management-api
# 3️⃣ Install dependencies
composer install
# 4️⃣ Copy environment file
cp .env.example .env
# 5️⃣ Generate app key
php artisan key:generate
# for composer
php artisan composer install
# 6️⃣ Configure database in .env
# (update DB_DATABASE, DB_USERNAME, DB_PASSWORD)
# 7️⃣ Run migrations and seed data
php artisan migrate --seed
# 8️⃣ Start the local server
php artisan serve
# 9️⃣ For broadcasting (optional)
php artisan queue:workInstall:
composer require --dev knuckleswtf/scribe
php artisan scribe:installGenerate:
php artisan scribe:generateVisit:
/docs
Amr — Laravel Backend Developer
Building maintainable, real-time backend systems ⚡