spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.6k stars 72 forks source link

Support for Eloquent #134

Closed khalyomede closed 4 months ago

khalyomede commented 8 months ago

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();
spatie-bot commented 4 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.