Welcome Guest, Not a member yet? Register   Sign In
Inaccuracy? Edit Entity attributes
#5

(07-30-2022, 10:54 PM)iRedds Wrote: Remove the 'date_birth' field from the $dates property.
If you need to receive the Time object for this field, then specify $casts = ['date_birth' => 'datetime'] in the property.

I don't know who decided that when setting the value of the field specified in the $dates property, turn the value into an object.
Thank you. This fixes the issue.

Code:
$user->hasChanged() boolean true
$user->toRawArray(...) array (1)
    date_birth => string (10) "1987-11-06"

Question: Why use $dates if it only applies to created_at deleted_at updated_at?

Now I met one more shortcoming: setAttributes() during find() findAll() cannot set attributes not from $datamap list. For example


PHP Code:
$this->fullName $this->firstName ' ' $this->lastName 
Otherwise, a few adjustments are needed for this action in fill() __construct() setAttributes() to set $fullName.
What for? To make the attribute available with new User($data) $user->fill($data)

Reply


Messages In This Thread
Inaccuracy? Edit Entity attributes - by ozornick - 07-29-2022, 12:44 PM
RE: Inaccuracy? Edit Entity attributes - by ozornick - 07-30-2022, 11:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB