urameshibr / pg-interval-support
Support for interval field type in PostgreSQL databases.
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.6.4
This package is auto-updated.
Last update: 2024-12-12 06:12:57 UTC
README
Support for interval field type in PostgreSQL databases.
How to install
composer require urameshibr/pg-interval-support
- Add the service provider in config/app.php
'providers' => [
// Other providers
Urameshibr\PgIntervalSupport\Providers\PostgresTypeGrammarIntervalServiceProvider::class,
],
Usage
- How to add a field with "interval" type in your migration file
$table->addColumn('interval', 'field_name')
- How to query that interval field
// The format: DB::table('table_name')->whereInterval('field_name', 'operator', 'interval') // Example 1 DB::table('tours')->whereInterval('duration', '>=', '02:00:00')->get() // Example 2 DB::table('tours')->whereInterval('duration', '>=', '2 hours')->get() // Example 3 YourModel::whereInterval('duration', '>=', '2 hours')->get()
- Observation: The method "whereInterval( )" work's with Query Builder Object
Enjoy!