getKey(); DB::table('form_field_bindings') ->where('owner_type', $ownerType) ->where('owner_id', $ownerId) ->delete(); if (Schema::hasTable('form_field_validation_rules')) { DB::table('form_field_validation_rules') ->where('owner_type', $ownerType) ->where('owner_id', $ownerId) ->delete(); } if (Schema::hasTable('form_field_configs')) { DB::table('form_field_configs') ->where('owner_type', $ownerType) ->where('owner_id', $ownerId) ->delete(); } if (Schema::hasTable('form_field_options')) { DB::table('form_field_options') ->where('owner_type', $ownerType) ->where('owner_id', $ownerId) ->delete(); } // Conditional-logic groups only apply to FormField (addendum Q3: // library mirror is out of scope). Condition rows cascade via // the group_id FK on the conditions table. if ($owner instanceof FormField && Schema::hasTable('form_field_conditional_logic_groups')) { DB::table('form_field_conditional_logic_groups') ->where('form_field_id', $ownerId) ->delete(); } } }