LaravelPackages.net
Acme Inc.
Toggle sidebar
primitive/flexible-where-between

3
15
0.2
About primitive/flexible-where-between

primitive/flexible-where-between is a Laravel package. It currently has 15 GitHub stars and 3 downloads on Packagist (latest version 0.2). Install it with composer require primitive/flexible-where-between. Discover more Laravel packages by primitive or browse all Laravel packages to compare alternatives.

Last updated

Latest Version on Packagist Total Downloads

image

We created this package to avoid duplication of code accross projects when using Laravel's whereBetween method.

For example, if you are looking for "something" between two dates, your method without this package would need to look like:

$logs = Log::query();

if ((empty($end_date) && (empty($start_date))
{
    $logs = $logs->get();
}

else if (empty($end_date)) 
{
   $logs = $logs->where('created_at','>=', $start_date);
}
else if (empty($start_date)) 
{
   $logs = $logs->where('created_at','<=', $end_date);
} 
else 
{
   $logs = $logs->whereBetween('created_at', [$start_date, $end_date])
}

This package takes care of that logic for you. Your new method would look like:

Log::whereBetween('created_at', [$start_date, $end_date])

So, regardless of whether $start_date or $end_date is NULL or has a value, it will "just work".

Installation

You can install the package via composer:

composer require primitive/flexible-where-between

Usage

After the package is installed, a macro is registered that overrides the default whereBetween functionality. So, it just works. :)

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments