Skip to content

Jigar-CS/Smart_Office_Employee_and_Task_Management_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Office – Employee & Task Management System API

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.


🎯 Table of Contents


✨ Features

  • 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

πŸ›  Tech Stack

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

πŸ“‹ Requirements

  • PHP 8.2 or higher
  • Composer (Dependency Manager)
  • MySQL 5.7+ or MariaDB 10.2+
  • Node.js & npm (optional, for frontend assets if needed)

Badges:
PHP Laravel License


πŸš€ Installation

1. Clone the Repository

git clone <your-repo-url>
cd Smart_Office_Employee_and_Task_Management_System_API

2. Install Dependencies

composer install

3. Set Up Environment File

Cross-platform (Linux/Mac):

cp .env.example .env

Windows PowerShell:

Copy-Item .env.example .env

4. Generate Application Key

php artisan key:generate

5. Run Migrations & Seeders

php artisan migrate --seed
php artisan storage:link

6. Start the Development Server

php artisan serve

The API will be available at: http://127.0.0.1:8000


βš™οΈ Configuration

Edit the .env file with your environment-specific settings:

Database Configuration

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=smart_office_db
DB_USERNAME=root
DB_PASSWORD=your_password

Application Settings

APP_NAME="Smart Office"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Sanctum Configuration

SANCTUM_STATEFUL_DOMAINS=localhost:3000,localhost:8000

File Storage

FILESYSTEM_DRIVER=public

πŸ—„οΈ Database & Seeders

Database Structure

The 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

Migrations

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

Seeders

Seeders are located in database/seeders/:

# Seed specific seeder
php artisan db:seed --class=MasterTablesSeeder

# Seed all seeders
php artisan db:seed

πŸ” Authentication

This API uses Laravel Sanctum for token-based authentication.

Login Endpoint

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

Using the Token

Include the token in all subsequent requests using the Authorization header:

curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc..." \
  http://127.0.0.1:8000/api/getalltask

Logout Endpoint

Endpoint: POST /api/logout

Requires a valid bearer token. Revokes the current authentication token.


πŸ“‘ API Endpoints

Public Endpoints (Authentication Required)

User Authentication

Method Endpoint Description
POST /api/userlogin Authenticate user and receive token
POST /api/logout Revoke current authentication token

Departments (Authenticated Users)

Method Endpoint Description
POST /api/getalldepartment Get all departments
POST /api/getdepartment Get single department by ID

Priorities (Authenticated Users)

Method Endpoint Description
POST /api/getallpriority Get all priority levels
POST /api/getpriority Get single priority by ID

Task Status (Authenticated Users)

Method Endpoint Description
POST /api/getalltaskstatus Get all task statuses
POST /api/gettaskstatus Get single task status by ID

Tasks (Authenticated Users)

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

Task Status Logs (Authenticated Users)

Method Endpoint Description
POST /api/getalltaskstatuslog Get all task status logs

User Profile (Authenticated Users)

Method Endpoint Description
POST /api/getalluser Get all users (Manager/Admin)
POST /api/updateprofile Update current user profile

Admin-Only Endpoints (Requires admin.token Middleware)

Department Management

Method Endpoint Description
POST /api/adddepartment Create new department
POST /api/updatedepartment Update department
POST /api/deletedepartment Delete department

Task Status Management

Method Endpoint Description
POST /api/addtaskstatus Create new task status
POST /api/updatetaskstatus Update task status
POST /api/deletetaskstatus Delete task status

Task Status Logs (Admin)

Method Endpoint Description
POST /api/addtaskstatuslog Create status log entry
POST /api/updatetaskstatuslog Update status log
POST /api/deletetaskstatuslog Delete status log

User Management

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

Role Management

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

Document Management

Method Endpoint Description
POST /api/getalldocument Get all documents
POST /api/getdocument Get single document

Task Assignments

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

πŸ“ Example Requests

Login Example

curl -X POST http://127.0.0.1:8000/api/userlogin \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "password": "password123"
  }'

Get All Tasks

curl -X POST http://127.0.0.1:8000/api/getalltask \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json"

Create New Task (Manager/Admin)

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"
  }'

Update User Profile

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"
  }'

Create Department (Admin Only)

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"
  }'

πŸ“ Project Structure

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

πŸ§ͺ Running Tests

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

Test files are located in tests/Feature/ and tests/Unit/.


🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Before Submitting a PR

  • 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

πŸ“„ License

This project is open-source software licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages