Aronaman
4 months ago
337
3
Laravel

DataBase Structure

Posted 4 months ago by Aronaman

i have this table and I have the problem of check availability in a range of date


room:

 -id
 -quantity
 -price
 -room_type_id(belongsTo) 
-organization_id(belongsTo)

*****
roomReservation: 

-id 
-check_in
 -check_out 
-quantity 
-sub_total 
-vat 
-total
-validation_code 
-user_id(belongsToMany)
 -room_id(belongsTo)
 -book_status_id( belongsTo)

****
roomTypes:

 -id 
-name
- desc
organization :
-id
 -region_id
 -city_id
 -averge_price
 -desc
  -is_feature

******
book_status:
 -id 
-name
 -desc

I struggle with check availability of rooms with check-in and checkout and while room reserve in specific input of check-in checkout the room quantity should decrease (room_quantity-reservation_quantity) in that time range. for me it hard:)

I try to "morph to" relationship like this room_table I add $table->morph("bookable"); on the reservation, I also add morph() for a user and bookable then I create a new table available (almost similar column like room reservation). still confuse.

and this makes me try marathon :).

any help, please !!

Please sign in or create an account to participate in this conversation.