Skip to content

Commit 764ceb1

Browse files
committed
Revert changes in Model;
1 parent 2ce8c57 commit 764ceb1

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

src/Eloquent/Model.php

+43-43
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,32 @@ public function getAttribute($key)
201201
return parent::getAttribute($key);
202202
}
203203

204-
/** @inheritdoc */
205-
protected function transformModelValue($key, $value)
206-
{
207-
$value = parent::transformModelValue($key, $value);
208-
if ($this->hasCast($key) && $value instanceof DateTimeInterface) {
209-
$value->settings(array_merge($value->getSettings(), ['toStringFormat' => $this->getDateFormat()]));
210-
211-
$castType = $this->getCasts()[$key];
212-
if ($this->isCustomDateTimeCast($castType) && str_starts_with($castType, 'date:')) {
213-
$value->startOfDay();
214-
}
215-
}
216-
217-
return $value;
218-
}
219-
220-
/** @inheritdoc */
221-
protected function getCastType($key)
222-
{
223-
$castType = $this->getCasts()[$key];
224-
if ($this->isCustomDateTimeCast($castType) || $this->isImmutableCustomDateTimeCast($castType)) {
225-
$this->setDateFormat(Str::after($castType, ':'));
226-
}
227-
228-
return parent::getCastType($key);
229-
}
204+
// /** @inheritdoc */
205+
// protected function transformModelValue($key, $value)
206+
// {
207+
// $value = parent::transformModelValue($key, $value);
208+
// if ($this->hasCast($key) && $value instanceof DateTimeInterface) {
209+
// $value->settings(array_merge($value->getSettings(), ['toStringFormat' => $this->getDateFormat()]));
210+
//
211+
// $castType = $this->getCasts()[$key];
212+
// if ($this->isCustomDateTimeCast($castType) && str_starts_with($castType, 'date:')) {
213+
// $value->startOfDay();
214+
// }
215+
// }
216+
//
217+
// return $value;
218+
// }
219+
220+
// /** @inheritdoc */
221+
// protected function getCastType($key)
222+
// {
223+
// $castType = $this->getCasts()[$key];
224+
// if ($this->isCustomDateTimeCast($castType) || $this->isImmutableCustomDateTimeCast($castType)) {
225+
// $this->setDateFormat(Str::after($castType, ':'));
226+
// }
227+
//
228+
// return parent::getCastType($key);
229+
// }
230230

231231
/** @inheritdoc */
232232
protected function getAttributeFromArray($key)
@@ -299,23 +299,23 @@ public function fromJson($value, $asObject = false)
299299
return Json::decode($value ?? '', ! $asObject);
300300
}
301301

302-
/** @inheritdoc */
303-
protected function castAttribute($key, $value)
304-
{
305-
$castType = $this->getCastType($key);
306-
307-
switch ($castType) {
308-
case 'immutable_custom_datetime':
309-
case 'immutable_datetime':
310-
if (str_starts_with($this->getCasts()[$key], 'immutable_date:')) {
311-
return $this->asDate($value)->toImmutable();
312-
}
313-
314-
return $this->asDateTime($value)->toImmutable();
315-
default:
316-
return parent::castAttribute($key, $value);
317-
}
318-
}
302+
// /** @inheritdoc */
303+
// protected function castAttribute($key, $value)
304+
// {
305+
// $castType = $this->getCastType($key);
306+
//
307+
// switch ($castType) {
308+
// case 'immutable_custom_datetime':
309+
// case 'immutable_datetime':
310+
// if (str_starts_with($this->getCasts()[$key], 'immutable_date:')) {
311+
// return $this->asDate($value)->toImmutable();
312+
// }
313+
//
314+
// return $this->asDateTime($value)->toImmutable();
315+
// default:
316+
// return parent::castAttribute($key, $value);
317+
// }
318+
// }
319319

320320
/** @inheritdoc */
321321
public function attributesToArray()

0 commit comments

Comments
 (0)