cheeasy-tech / laravel-multibooking
Implementation of multi-booking for Laravel
dev-main
2024-09-06 00:22 UTC
Requires
- php: >=8.2
- laravel/framework: ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- ergebnis/composer-normalize: ^2.43
- pestphp/pest: >=2.35.1
This package is auto-updated.
Last update: 2024-09-06 00:22:13 UTC
README
Laravel Mutli-Booking is a flexible multi-booking system for Laravel applications. It allows users to book various processes (e.g., training sessions, seminars) that implement the BookableContract
.
Installation
To install the package, simply run:
composer require cheeasytech/laravel-multi-booking
Publish Config and Migrations
Once installed, you can publish the configuration file and migrations:
php artisan vendor:publish --provider="CheesyTech\LaravelBooking\BookingServiceProvider" --tag="config" php artisan vendor:publish --provider="CheesyTech\LaravelBooking\BookingServiceProvider" --tag="migrations"
Run the migrations to create the necessary tables:
php artisan migrate
Configuration
In the config/booking.php
file, set the user model for the system:
return [ 'user_model' => \App\Models\User::class, ];
Usage
Defining Bookable Entities
Any process that can be booked (like a seminar or a training session) should implement the BookableContract.
For example:
namespace App\Models; use CheeasyTech\LaravelBooking\BookableContract; use Illuminate\Database\Eloquent\Model; class TrainingSession extends Model implements BookableContract { public function getBookableId(): int { return $this->id; } public function getBookableType(): string { return static::class; } }
User Bookings
Users can book processes (e.g., training sessions) using the book method.
// Get all bookings for a user $user->bookings;