Add support for immutable carbon dates in models

This commit is contained in:
Dane Everitt 2020-04-03 23:22:35 -07:00
parent 6d1226a0c1
commit f51d65229b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
20 changed files with 79 additions and 26 deletions

View file

@ -0,0 +1,20 @@
<?php
namespace Pterodactyl\Models\Traits;
/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
trait WithImmutableDates
{
/**
* Converts the mutable Carbon instance into an immutable Carbon instance.
*
* @param mixed $value
* @return \Carbon\CarbonImmutable
*/
protected function asImmutableDateTime($value)
{
return $this->asDateTime($value)->toImmutable();
}
}