I have a Laravel Eloquent model observer observing the updated event on a given model, looking for changes in certain values.
If the value has changed I want to perform some action.
The abridged code:
// Check the lessonRequest to see what's changed
if($lessonRequest->subject_id !== $lessonRequest->getOriginal('subject_id')){
$msg = __('app.lesson_request_subject_changed', ['name' => Auth::user()->name, 'subject' => $lessonRequest->subject->title]);
$lessonResource = LessonResource::createChatMessage($lessonRequest->id, $msg, null);
$lessonResource->save();
}
Unfortunately, the subject relationship on the $lessonRequest object still has the previous subject, rather than the record defined by the ID that was updated.
Is this deliberate behaviour, or have I done something wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire