Skip to content

Commit

Permalink
feat: add caster PgPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
efureev committed Feb 8, 2022
1 parent 53ab2dd commit 328f302
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
],
"require": {
"php": "^8.0",
"efureev/support": "^4.4.3",
"illuminate/database": "^8.70"
"efureev/support": "^4.8",
"illuminate/database": "^8.78"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^6.23",
"orchestra/testbench": "^6.24",
"squizlabs/php_codesniffer": "^3.6",
"fakerphp/faker": "^1.16"
"fakerphp/faker": "^1.17"
},
"autoload": {
"files": [
Expand Down
20 changes: 20 additions & 0 deletions src/Caster/PgPoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Php\Support\Laravel\Caster;

use Php\Support\Helpers\Arr;

class PgPoint extends PgArray
{
public static function castToDatabase($value): ?string
{
return Arr::toPostgresPoint(static::normalize($value));
}

public function castFromDatabase(?string $value): array
{
return Arr::fromPostgresPoint($value);
}
}

0 comments on commit 328f302

Please sign in to comment.