项目作者: ahmed-hamdy90

项目描述 :
Create Restful API for Booking Bus trips job task
高级语言: PHP
项目地址: git://github.com/ahmed-hamdy90/booking_trips_job_task.git
创建时间: 2020-06-27T23:06:25Z
项目社区:https://github.com/ahmed-hamdy90/booking_trips_job_task

开源协议:

下载


Simple Booking trips system Using Laravel 7+

Booking trips system include check for available trips into one day, plus booking any available seat under trip.
any trip can be direct trip (like Cairo to Alexandria trip) or trip include more than one stop stations between pickup station and final station
(like Cairo, tanta, alexandria trip) So user can booking any internal trip only not the full one.

To access application’s source code under src folder

project’s technologies stack: PHP, MySql, Laravel 7+, Eloquent

project depend on Laravel migrations to setup MySql Database schema (see src/database/migrations), also setting dummy data using Laravel Seeder (see src/database/seeds),
here simple schema

  1. db:
  2. - Cities table -> id, name, code
  3. - Trips table -> id, departure_city_id, destination_city_id, date, departure_time, expected_trip_hours, expected_trip_minutes, expected_trip_seconds, total_seats_number, parent_trip_id, available_seats_number
  4. - Trips_booking_seats table -> trip_id, seat_number, booking_user_name, booking_user_email

project Can Run using Vagrant box, To install vagrant See official Doc you must install virtualBox first See official Doc

How To Run Simple

  • create your own .env file, to setting Mysql Database,
    (configuration for vagrant box only)

    1. DB_CONNECTION=mysql
    2. DB_HOST=127.0.0.1
    3. DB_PORT=3306
    4. DB_DATABASE=rubosta_task_db -> change with your db_name
    5. DB_USERNAME=vagrant -> change with your admin username
    6. DB_PASSWORD=vagrant -> change with your admin passord
  • Run Vagrant box
    shell script vagant up

  • using Postman

    1. http://localhost:8686/api/trips
Possible Routes
  • [GET] Retrieve the available trips for day,
    Take three mandatory query string:

    • form: represent city’s code which user will be pickup (first station)
    • to: represent city’s code which user will land into (final station)
    • date: represent day which need to check available trips, take format YYYY-mm-dd
      1. http://localhost:8686/api/trips
      Example:
      1. http://localhost:8686/api/trips?from=CA&to=FA&date=2020-06-27
  • [POST] Booking any available seat into exists trip,
    post Data as Json consist of:

    • tripId: represent trip id value
    • user object: represent user information, name and email
      1. http://localhost:8686/api/booking-trip
      Example: Here POST data and the same above url
      1. {
      2. "tripId": 1,
      3. "user": {
      4. "name": "ahmed",
      5. "email": "ahmed@test.com"
      6. }
      7. }

Notices:

  • To access code under Vagrant box
    ```shell script
    vagrant ssh

cd /var/www/src
```

TODO:

  • Fix bug of determine new booking Seat number

  • create unit test for exists the domain services classes

  • using .travis CI

  • Using Docker to Run project beside Vagrant box