PHPackages                             primitive/flexible-where-between - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. primitive/flexible-where-between

ActiveLibrary[Database &amp; ORM](/categories/database)

primitive/flexible-where-between
================================

0.2(5y ago)1531MITPHPPHP ^7.1

Since Oct 30Pushed 5y ago2 watchersCompare

[ Source](https://github.com/PrimitiveSocial/flexible-where-between)[ Packagist](https://packagist.org/packages/primitive/flexible-where-between)[ Docs](https://github.com/primitivesocial/flexible-where-between)[ RSS](/packages/primitive-flexible-where-between/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d16eb9dbd4e6584d054521a41d3804d4c40792c19004fd08babd241344040730/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7072696d69746976652f666c657869626c652d77686572652d6265747765656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/primitive/flexible-where-between)[![Total Downloads](https://camo.githubusercontent.com/113f6aec40755f6f8c91b7ece53bd674187ca024fb6ca016dce48b02a6e84138/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7072696d6974697665732f666c657869626c652d77686572652d6265747765656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/primitive/flexible-where-between)

[![image](https://user-images.githubusercontent.com/13042804/97702236-a4ea0880-1a7c-11eb-940a-ee99796f6044.png)](https://user-images.githubusercontent.com/13042804/97702236-a4ea0880-1a7c-11eb-940a-ee99796f6044.png)

We created this package to avoid duplication of code accross projects when using [Laravel's](https://laravel.com) `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','
