You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a character and character_log stored in DB.
Now i would like to delete the relational character_log entry and keep the character entry. Therefore I have a deleteLog(); method in the CharacterModel Class:
This works but it does not seem to be the "right" way :) - The $this->save() is required, after erasing the character_log relation, to get a "updated" character model without the log. The second var_dump() (var_dump($this->cast());) still has the relational object. Is there a way to "auto-save" $this when a relation object was removed?
This works as well but in any case, i have to use the returned $test variable,$this is not automatically updated after save. Is there are more elegant way to achieve what i want.
The text was updated successfully, but these errors were encountered:
Hi,
I´m looking for the most elegant/clean way, for deleting
has-one
relations.Setup:
I have a
character
andcharacter_log
stored in DB.Now i would like to delete the relational
character_log
entry and keep thecharacter
entry. Therefore I have adeleteLog();
method in the CharacterModel Class:This works but it does not seem to be the "right" way :) - The
$this->save()
is required, after erasing thecharacter_log
relation, to get a "updated"character
model without the log. The second var_dump() (var_dump($this->cast());
) still has the relational object. Is there a way to "auto-save" $this when a relation object was removed?Then i tried something like this:
This does not delete the
character_log
row, it just setcharacterId
column tonull
. And finally i tried this:This works as well but in any case, i have to use the returned
$test
variable,$this
is not automatically updated after save. Is there are more elegant way to achieve what i want.The text was updated successfully, but these errors were encountered: