Support for interval field type in PostgreSQL databases.
composer require urameshibr/pg-interval-support
- Add the service provider in config/app.php
'providers' => [
// Other providers
Urameshibr\PgIntervalSupport\Providers\PostgresTypeGrammarIntervalServiceProvider::class,
],
- 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!