period
period copied to clipboard
Support for Eloquent
Hello, thank you for this package, really useful! I wonder if you are willing to support eloquent scopes to perform similar results? My use case would be to check if a booking is overlapping a given period.
return new class extends Migration
{
public function up(): void
{
Schema::create("bookings", function (Blueprint $table) {
$table->id();
$table->dateTime("starts_at");
$table->dateTime("ends_at");
$table->timestamps();
});
}
};
use App\Models\Booking;
use Spatie\Period\Period;
$period = Period::make("2024-01-24 10:00:00", "2024-01-24 19:00:00");
$bookings = Booking::overlapping($period)->get();