mercredi 28 juin 2017

Handling concurrency in a booking sistem with laravel

I'm developing a REST api in Laravel 5.2 with postgresql that handles bookings for diferent establishments that have an start_time and an end_time. The user can see in the frontend the diferents times available in a certain establishments and make a booking. Here is the problematic situation:

  1. Customer A wants to book an establishment. Sees that the establishment A is free from 15:00 hs to 20:00 hs
  2. Customer A selects the 16:00 to 17:00 time. (Have to press a button to confirm the booking)
  3. Customer B wants to book an establishment. Sees that the establishment A is free from 15:00 hs to 20:00
  4. Customer B selects the 16:00 to 17:00 apointment (Again, have to press a button to confirm the booking)
  5. Customer A confirms the booking
  6. If customer B confirms the booking, we will have 2 bookings at the same time.

Have read a lot about queues in laravel and I'm not really sure if that is the correct way to solve this problem.

The establishments doesnt have arbitrary hours so the customers can pick up a 1 or 2 or 3 hours booking.

This is my booking model

    Schema::create('bookings', function (Blueprint $table) {
        $table->increments('id');
        $table->timestamps();
        $table->timestamp('start_time');
        $table->timestamp('end_time');
        $table->integer('user_id')->nullable();
        $table->integer('establishment_id')->nullable();
        $table->string('name')->nullable();
        $table->string('phone_number')->nullable();

    });



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sS0DBA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire