@@ -27,7 +27,6 @@ class InterfaceLAGG extends Model {
2727
2828 # Set model fields
2929 $ this ->laggif = new StringField (
30- required: true ,
3130 read_only: true ,
3231 maximum_length: 32 ,
3332 help_text: 'The real name of the LAGG interface. ' ,
@@ -126,8 +125,7 @@ class InterfaceLAGG extends Model {
126125 }
127126
128127 /**
129- * Extends the default _delete method to prevent deletion of the LAGG interface if it is in use, and remove
130- * the LAGG interface from the system if it is not in use.
128+ * Extends the default _delete method to prevent deletion of the LAGG interface if it is in use.
131129 */
132130 public function _delete (): void {
133131 # Query for an interface using this lagg
@@ -140,8 +138,30 @@ class InterfaceLAGG extends Model {
140138 );
141139 }
142140
143- # Remove the LAGG interface from the system
144- pfSense_interface_destroy ($ this ->laggif ->value );
145141 parent ::_delete ();
146142 }
143+
144+ /**
145+ * Reconfigures VLANs and interfaces using this LAGG after successful creation or update.
146+ */
147+ public function apply (): void {
148+ # Check for interfaces using this LAGG and reconfigure them
149+ $ if_q = NetworkInterface::query (if: $ this ->laggif ->value );
150+ foreach ($ if_q ->model_objects as $ if ) {
151+ interface_configure ($ if ->id );
152+ }
153+
154+ # Check for VLANs using this LAGG and reconfigure them
155+ $ vlan_q = InterfaceVLAN::query (if: $ this ->laggif ->value );
156+ foreach ($ vlan_q ->model_objects as $ vlan ) {
157+ interface_vlan_configure ($ vlan ->to_internal ());
158+ }
159+ }
160+
161+ /**
162+ * Applies the deletion of this LAGG interface.
163+ */
164+ public function apply_delete (): void {
165+ pfSense_interface_destroy ($ this ->laggif ->value );
166+ }
147167}
0 commit comments