composer require sunaoka/laravel-postgres-extension
php artisan vendor:publish --tag=postgres-extension
-
RETURNING
- UPDATE
- DELETE
-
Caching "information_schema" table.
-
Range Types
- Depends on sunaoka/laravel-postgres-range
CREATE TABLE some_models
(
id bigserial PRIMARY KEY NOT NULL,
code text NOT NULL,
term tsrange NOT NULL,
CONSTRAINT code_uq UNIQUE (code)
);
<?php
namespace App\Models;
class SomeModel extends \Sunaoka\LaravelPostgres\Eloquent\Model
{
protected $casts = [
'term' => \Sunaoka\LaravelPostgres\Eloquent\Casts\TsRangeCast::class, // tsrange
];
}
$some = SomeModel::whereId(1)
->returning(['*'])
->update([
'term' => new TsRange('2020-09-01 00:00:00', '2020-09-01 23:59:59'),
]);
echo get_class($some);
// => Illuminate\Database\Eloquent\Collection
echo get_class($some->first());
// => App\Models\SomeModel
update "some_models"
set "term" = '[2020-09-01 00:00:00,2020-09-01 23:59:59)'
where "id" = '1'
returning *
Permanently cache the results for a table like the one below.
select *
from information_schema.tables
where table_schema = 'public' and table_name = 'some_models'