mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 06:13:45 +02:00
Add support for immutable carbon dates in models
This commit is contained in:
20
app/Models/Traits/WithImmutableDates.php
Normal file
20
app/Models/Traits/WithImmutableDates.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user