A modern, lightweight Laravel REST API for managing employees, departments, tasks, priorities, documents, and activity logs. Built to power the Smart Office application with role-based access control, task assignments, and comprehensive activity tracking.
- Features
- Tech Stack
- Requirements
- Installation
- Configuration
- Database & Seeders
- Authentication
- API Endpoints
- Example Requests
- Project Structure
- Running Tests
- Contributing
- License
- User Management: Create, read, update, and delete users with role-based access control
- Department Management: Organize employees by departments
- Task Management: Create, assign, and track tasks with priorities and status logs
- Task Assignments: Assign tasks to users with detailed tracking
- Priority & Status Management: Configure task priorities and statuses for your workflow
- Activity Logging: Track all task status changes with detailed logs
- Document Management: Store and manage documents associated with tasks
- Authentication: Secure token-based authentication using Laravel Sanctum
- Authorization: Role-based and middleware-driven access control
- Database Migrations & Seeders: Pre-built migrations for all entities and seeders for master data
| Technology | Version | Purpose |
|---|---|---|
| PHP | ^8.2 | Language |
| Laravel | ^12.0 | Web Framework |
| Laravel Sanctum | ^4.0 | API Authentication |
| MySQL / MariaDB | Latest | Database |
| Composer | Latest | Dependency Management |
- PHP 8.2 or higher
- Composer (Dependency Manager)
- MySQL 5.7+ or MariaDB 10.2+
- Node.js & npm (optional, for frontend assets if needed)
git clone <your-repo-url>
cd Smart_Office_Employee_and_Task_Management_System_APIcomposer installCross-platform (Linux/Mac):
cp .env.example .envWindows PowerShell:
Copy-Item .env.example .envphp artisan key:generatephp artisan migrate --seed
php artisan storage:linkphp artisan serveThe API will be available at: http://127.0.0.1:8000
Edit the .env file with your environment-specific settings:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=smart_office_db
DB_USERNAME=root
DB_PASSWORD=your_passwordAPP_NAME="Smart Office"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSANCTUM_STATEFUL_DOMAINS=localhost:3000,localhost:8000FILESYSTEM_DRIVER=publicThe application includes the following core entities:
| Table | Purpose |
|---|---|
| users | System users with roles and departments |
| roles | User roles (Admin, Manager, Employee) |
| departments | Organizational departments |
| tasks | Task records with title, description, due dates |
| task_assignments | Assignment of tasks to users |
| task_statuses | Task status definitions (Pending, In Progress, Completed) |
| task_status_logs | Historical logs of task status changes |
| priorities | Task priority levels (Low, Medium, High, Critical) |
| documents | Document storage for tasks |
All database migrations are located in database/migrations/:
# Run all pending migrations
php artisan migrate
# Rollback last migration batch
php artisan migrate:rollback
# Reset and reseed the database (β οΈ Destructive)
php artisan migrate:fresh --seedSeeders are located in database/seeders/:
# Seed specific seeder
php artisan db:seed --class=MasterTablesSeeder
# Seed all seeders
php artisan db:seedThis API uses Laravel Sanctum for token-based authentication.
Endpoint: POST /api/userlogin
Request:
{
"email": "user@example.com",
"password": "password123"
}Response:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"user": {
"id": 1,
"name": "Admin User",
"email": "user@example.com",
"role_id": 1
}
}Include the token in all subsequent requests using the Authorization header:
curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc..." \
http://127.0.0.1:8000/api/getalltaskEndpoint: POST /api/logout
Requires a valid bearer token. Revokes the current authentication token.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/userlogin |
Authenticate user and receive token |
POST |
/api/logout |
Revoke current authentication token |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalldepartment |
Get all departments |
POST |
/api/getdepartment |
Get single department by ID |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getallpriority |
Get all priority levels |
POST |
/api/getpriority |
Get single priority by ID |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalltaskstatus |
Get all task statuses |
POST |
/api/gettaskstatus |
Get single task status by ID |
| Method | Endpoint | Description | Authorization |
|---|---|---|---|
POST |
/api/getalltask |
Get all tasks | Any User |
POST |
/api/gettask |
Get single task | Assigned User |
POST |
/api/updatetask |
Update task | Assigned User |
POST |
/api/deletetask |
Delete task | Assigned User |
POST |
/api/createtask |
Create new task | Manager/Admin |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalltaskstatuslog |
Get all task status logs |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalluser |
Get all users (Manager/Admin) |
POST |
/api/updateprofile |
Update current user profile |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/adddepartment |
Create new department |
POST |
/api/updatedepartment |
Update department |
POST |
/api/deletedepartment |
Delete department |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/addtaskstatus |
Create new task status |
POST |
/api/updatetaskstatus |
Update task status |
POST |
/api/deletetaskstatus |
Delete task status |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/addtaskstatuslog |
Create status log entry |
POST |
/api/updatetaskstatuslog |
Update status log |
POST |
/api/deletetaskstatuslog |
Delete status log |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getuser |
Get single user details |
POST |
/api/createuser |
Create new user |
POST |
/api/updateuser |
Update user information |
POST |
/api/deleteuser |
Delete user account |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getallrole |
Get all roles |
POST |
/api/getrole |
Get single role |
POST |
/api/addrole |
Create new role |
POST |
/api/updaterole |
Update role |
POST |
/api/deleterole |
Delete role |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalldocument |
Get all documents |
POST |
/api/getdocument |
Get single document |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/getalltaskassignment |
Get all task assignments |
POST |
/api/gettaskassignment |
Get single task assignment |
POST |
/api/updatetaskassignment |
Update task assignment |
POST |
/api/deletetaskassignment |
Delete task assignment |
curl -X POST http://127.0.0.1:8000/api/userlogin \
-H "Content-Type: application/json" \
-d '{
"email": "admin@example.com",
"password": "password123"
}'curl -X POST http://127.0.0.1:8000/api/getalltask \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"curl -X POST http://127.0.0.1:8000/api/createtask \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Complete Project Report",
"description": "Prepare quarterly project report",
"priority_id": 2,
"department_id": 1,
"due_date": "2026-06-30"
}'curl -X POST http://127.0.0.1:8000/api/updateprofile \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"phone": "+1234567890"
}'curl -X POST http://127.0.0.1:8000/api/adddepartment \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Marketing",
"description": "Marketing Department"
}'smart-office-api/
βββ app/
β βββ Http/
β β βββ Controllers/ # API route controllers
β β β βββ AuthController.php
β β β βββ UserController.php
β β β βββ TaskModelController.php
β β β βββ DepartmentModelController.php
β β β βββ ...
β β βββ Middleware/ # Custom middleware for auth & authorization
β βββ Models/ # Eloquent models
β β βββ User.php
β β βββ TaskModel.php
β β βββ DepartmentModel.php
β β βββ ...
β βββ Services/ # Business logic services
βββ bootstrap/
β βββ app.php
β βββ providers.php
βββ config/ # Configuration files
β βββ app.php
β βββ auth.php
β βββ database.php
β βββ sanctum.php
β βββ ...
βββ database/
β βββ migrations/ # Database migration files
β βββ seeders/ # Database seeders
β βββ factories/ # Model factories for testing
βββ routes/
β βββ api.php # API routes
β βββ web.php # Web routes
β βββ console.php
βββ storage/ # Logs and file uploads
βββ tests/ # Unit & feature tests
βββ vendor/ # Composer dependencies
βββ .env.example # Example environment file
βββ composer.json # PHP dependencies
βββ phpunit.xml # PHPUnit configuration
βββ vite.config.js # Vite configuration
βββ README.md # This file
Run the PHPUnit test suite to validate the application:
# Run all tests
php artisan test
# Run specific test file
php artisan test tests/Feature/AuthTest.php
# Run tests with coverage report
php artisan test --coverage
# Run using phpunit directly
vendor/bin/phpunitTest files are located in tests/Feature/ and tests/Unit/.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Ensure all tests pass:
php artisan test - Follow Laravel coding standards
- Update documentation as needed
- Include migrations for any database changes
- Run seeders if adding new master data
This project is open-source software licensed under the MIT License. See the LICENSE file for details.