id) ->with('festivalSection') ->orderBy('priority') ->get(); } public function replacePreferences(Person $person, array $preferences): void { $old = PersonSectionPreference::where('person_id', $person->id)->get()->toArray(); DB::transaction(function () use ($person, $preferences): void { PersonSectionPreference::where('person_id', $person->id)->delete(); foreach ($preferences as $pref) { PersonSectionPreference::create([ 'person_id' => $person->id, 'festival_section_id' => $pref['festival_section_id'], 'priority' => $pref['priority'], ]); } }); $activityLogger = activity('section_preferences') ->performedOn($person) ->withProperties([ 'old' => $old, 'attributes' => $preferences, ]); if (auth()->user()) { $activityLogger->causedBy(auth()->user()); } $activityLogger->log('person.section_preferences.replaced'); } }