Download the PHP package shirokovnv/innkeeper without Composer
On this page you can find all versions of the php package shirokovnv/innkeeper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shirokovnv/innkeeper
More information about shirokovnv/innkeeper
Files in shirokovnv/innkeeper
Package innkeeper
Short Description The library for your next Laravel booking app
License MIT
Homepage https://github.com/shirokovnv/innkeeper
Informations about the package innkeeper
Innkeeper
The library for your next Laravel booking app.
Supported Laravel versions: >=9.x
Installation
-
Install package via composer
-
Run migrations
- Done!
Usage
Add bookable functionality to your eloquent model
That's basically it. Now your rooms can be booked.
Checking opportunity for the booking:
The Innkeeper
service provides functionality to check wether its possible to book something in a date range:
Create a new booking
Creating a new booking is straight forward and could be done the following way:
Or if you like facades, you can do it like this:
Notes:
Why we need
booking_hash
and what is it ?
- The hash is a field in a database with a unique constraint
- It serves purpose to prevent some duplicate bookings without explicitly locking tables
Let me show you and example:
Suppose, you have a few visitors on your booking site. And all the visitors asks for booking the same room at a time.
In this particular case, you probably need to assign the room to the first customer and notify others the room already booked.
You can do it by these simple steps:
-
Define hash function
- In your business logic code
This example covers only the case, when you have deterministic booking schedule without intersections. Like this:
- 09:00 - 10:00
- 10:00 - 11:00
- 11:00 - 12:00
- ...
If you have some intersections, like:
- 09:00 - 10:00
- 09:30 - 10:30
you may still have a problem with duplicates.
Of course, you can check the availability of the room:
But it doesn't guarantee resolving concurrent requests for your schedule.
So, please, let me know what can be a solution if it is your case.
Query bookings
Delete bookings
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Shirokov Nickolai
- All Contributors
License
MIT. Please see the license file for more information.