A fleet-management system built with Laravel 11 that allows users to book bus seats for predefined trips with intermediate stations.
This project is a Laravel-based Fleet Management System that allows users to book seats on predefined bus trips between Egyptian cities. The system ensures that seats are only booked if they are available for the selected trip segment.
- Trip Management: Predefined trips between cities with intermediate stations.
- Seat Booking: Users can book seats for specific trip segments (e.g., Cairo to AlFayyum).
- Seat Availability: Users can check available seats for a trip segment.
- Validation: Proper validation for user inputs and seat availability.
- Authentication: Secure user authentication for booking seats.
- Database: Relational database design with proper normalization.
- APIs: RESTful APIs for seat booking and availability checking.
Before you begin, ensure you have the following installed:
- PHP (version 8.0 or higher)
- Composer (for dependency management)
- MySQL (or any compatible database)
- Git (for cloning the repository)
git clone https://github.com/mennaabdelelhady/SmartFleet.git
cd SmartFleet
Install PHP dependencies using Composer:
composer install
Create a new MySQL database for the project:
CREATE DATABASE smartfleet;
Import the database dump: Locate the SQL file in the smart fleet.sql. Import it into your database using a tool like phpMyAdmin or the MySQL command line:
mysql -u your_username -p smartfleet < database/smartfleet_dump.sql
Rename the .env.example
file to .env
:
cp .env.example .env
Update the .env
file with your database credentials and other settings:
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=smartfleet
DB_USERNAME=your_username
DB_PASSWORD=your_password
Generate an application key:
php artisan key:generate
Run the following commands to set up the database schema and seed initial data:
php artisan migrate
php artisan db:seed
Run the Laravel development server:
php artisan serve
The application will be accessible at http://localhost:8000.
You can use tools like Postman or cURL to test the API endpoints. Below are the available APIs:
Endpoint: GET /api/available-seats
Parameters:
start_station
: ID of the starting station.end_station
: ID of the destination station.
Example:
GET http://localhost:8000/api/available-seats?start_station=1&end_station=3
Endpoint: POST /api/book-seat
Parameters (JSON body):
trip_id
: ID of the trip.start_station
: ID of the starting station.end_station
: ID of the destination station.seat_id
: ID of the seat to book.
Example:
POST http://localhost:8000/api/book-seat
Body (JSON):
{
"trip_id": 1,
"start_station": 1,
"end_station": 3,
"seat_id": 5
}
The database schema is designed to support the fleet management system. Below is the Entity-Relationship Diagram (ERD):
- Seat Availability Logic: The system ensures that seats are only booked if they are available for the selected trip segment. If a bus is fully booked for a segment, users cannot book seats for overlapping segments.
- Validation: All user inputs are validated to prevent errors and ensure data integrity.
- Authentication: Users must authenticate to book seats. Laravel Sanctum can be used for API authentication.
SmartFleet/
├── app/ # Application logic
│ ├── Models/ # Database models
│ ├── Http/ # Controllers and middleware
│ └── ... # Other Laravel components
├── config/ # Configuration files
├── database/ # Database migrations, seeders, and dump
├── public/ # Publicly accessible files
├── routes/ # API and web routes
├── tests/ # Unit and feature tests
├── .env.example # Environment variables template
├── composer.json # Composer dependencies
└── README.md # Project documentation
If you’d like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.
- Vehikl
- Tighten Co.
- WebReinvent
- Kirschbaum Development Group
- 64 Robots
- Curotec
- Cyber-Duck
- DevSquad
- Jump24
- Redberry
- Active Logic
- byte5
- OP.GG
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.
The Laravel framework is open-sourced software licensed under the MIT license.