Skip to content

Commit d381e2f

Browse files
committed
add support for casting to timestamp
1 parent d696a7d commit d381e2f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace BlueFeather\EloquentFileMaker\Database\Eloquent\Concerns;
4+
5+
use Illuminate\Database\Eloquent\Concerns\HasAttributes;
6+
7+
trait FMHasAttributes
8+
{
9+
use HasAttributes;
10+
11+
/**
12+
* Determine whether a value is Date / DateTime castable for inbound manipulation.
13+
*
14+
* @param string $key
15+
* @return bool
16+
*/
17+
protected function isDateCastable($key)
18+
{
19+
// We need to also cast timestamps as
20+
return $this->hasCast($key, ['date', 'datetime', 'immutable_date', 'immutable_datetime', 'timestamp']);
21+
}
22+
23+
}

src/Database/Eloquent/FMModel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BlueFeather\EloquentFileMaker\Database\Eloquent;
44

55
use BlueFeather\EloquentFileMaker\Database\Eloquent\Concerns\FMGuardsAttributes;
6+
use BlueFeather\EloquentFileMaker\Database\Eloquent\Concerns\FMHasAttributes;
67
use BlueFeather\EloquentFileMaker\Database\Eloquent\Concerns\FMHasRelationships;
78
use BlueFeather\EloquentFileMaker\Database\Query\FMBaseBuilder;
89
use BlueFeather\EloquentFileMaker\Exceptions\FileMakerDataApiException;
@@ -19,6 +20,7 @@
1920
abstract class FMModel extends Model
2021
{
2122

23+
use FMHasAttributes;
2224
use FMHasRelationships;
2325
use FMGuardsAttributes;
2426

0 commit comments

Comments
 (0)