mercredi 6 novembre 2019

Indirect modification of overloaded property Model has no effect

This is a frequently asked question here, but it's the first time I'm encountering this problem and none of the other questions are exactly like mine.

As far as I'm concerned I'm copying Laravel's documentation exactly, but I'm getting this error. I assume it's to do with the sub-relationships between models.

    $attendance = AttendingActor::findOrFail($currentAttendance);
    $attendance->character->school_class_id = $classId;
    $attendance->character->save();

Why am I sometimes getting the following error?

Indirect modification of overloaded property App\Attendance::$character has no effect

And why if I change it to the following, do I get an error 100% of the time?

    $attendance = AttendingActor::findOrFail($currentAttendance);
    $attendance->character->schoolClass->id = $classId;
    $attendance->character->schoolClass->save();

The models AttendingActor and Character have a 1:1 relationship, so why is it problematic updating them in this way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire