|
12 | 12 | use Illuminate\Database\Eloquent\Relations\Pivot; |
13 | 13 | use Illuminate\Http\File; |
14 | 14 | use Illuminate\Http\UploadedFile; |
| 15 | +use Illuminate\Support\Arr; |
15 | 16 | use Illuminate\Support\Collection; |
16 | 17 | use Illuminate\Support\Str; |
17 | 18 |
|
@@ -471,55 +472,22 @@ public function getTable() |
471 | 472 | */ |
472 | 473 | public function setAttribute($key, $value) |
473 | 474 | { |
474 | | - // First we will check for the presence of a mutator for the set operation |
475 | | - // which simply lets the developers tweak the attribute as it is set on |
476 | | - // the model, such as "json_encoding" an listing of data for storage. |
477 | | - if ($this->hasSetMutator($key)) { |
478 | | - return $this->setMutatedAttributeValue($key, $value); |
479 | | - } |
480 | | - |
481 | | - // If an attribute is listed as a "date", we'll convert it from a DateTime |
482 | | - // instance into a form proper for storage on the database tables using |
483 | | - // the connection grammar's date format. We will auto set the values. |
484 | | - elseif ($value && $this->isDateAttribute($key)) { |
485 | | - $value = $this->fromDateTime($value); |
486 | | - |
487 | | - // When writing dates the regular datetime format won't work, so we have to get JUST the date value |
488 | | - |
489 | | - if ($this->casts[$key] === 'date') { |
490 | | - $exploded = explode(' ', $value); |
491 | | - $value = $exploded[0]; |
492 | | - } |
493 | | - } |
494 | | - |
495 | | - if ($this->isClassCastable($key)) { |
496 | | - $this->setClassCastableAttribute($key, $value); |
| 475 | + parent::setAttribute($key, $value); |
497 | 476 |
|
498 | | - return $this; |
499 | | - } |
500 | | - |
501 | | - if (!is_null($value) && $this->isJsonCastable($key)) { |
502 | | - $value = $this->castAttributeAsJson($key, $value); |
503 | | - } |
504 | | - |
505 | | - // If this attribute contains a JSON ->, we'll set the proper value in the |
506 | | - // attribute's underlying array. This takes care of properly nesting an |
507 | | - // attribute in the array's value in the case of deeply nested items. |
508 | | - if (Str::contains($key, '->')) { |
509 | | - return $this->fillJsonAttribute($key, $value); |
510 | | - } |
| 477 | + $value = $this->attributes[$key]; |
511 | 478 |
|
512 | | - if (!is_null($value) && $this->isEncryptedCastable($key)) { |
513 | | - $value = $this->castAttributeAsEncryptedString($key, $value); |
| 479 | + // When writing dates the regular datetime format won't work, so we have to get JUST the date value |
| 480 | + if ($this->isDateAttribute($key) && $this->hasCast($key, ['date'])) { |
| 481 | + $value = Arr::first(explode(' ', $value)); |
514 | 482 | } |
515 | 483 |
|
516 | 484 | // FileMaker can't handle true and false, so we need to change to 1 and 0 |
517 | | - if (is_bool($value)){ |
| 485 | + if (is_bool($value)) { |
518 | 486 | $value = $value ? 1 : 0; |
519 | 487 | } |
520 | 488 |
|
521 | 489 | // FileMaker can't handle null, so change it to '' |
522 | | - if (is_null($value)){ |
| 490 | + if (is_null($value)) { |
523 | 491 | $value = ''; |
524 | 492 | } |
525 | 493 |
|
|
0 commit comments