['uploadable_type'], 'model_has_permissions' => ['model_type'], 'model_has_roles' => ['model_type'], 'media' => ['model_type'], 'transfers' => ['transferable_type'], ]; DB::beginTransaction(); try { foreach ($tablesAndColumns as $table => $columns) { foreach ($columns as $column) { DB::table($table) ->where($column, 'LIKE', "{$oldNamespace}%") ->where($column, 'NOT LIKE', "{$newNamespace}%") // جلوگیری از اعمال تکراری ->update([ $column => DB::raw("REPLACE(`{$column}`, '{$oldNamespace}', '{$newNamespace}')") ]); } } DB::commit(); $this->info("Model namespaces updated successfully."); } catch (\Exception $e) { DB::rollBack(); $this->error("Error updating model namespaces: " . $e->getMessage()); } return CommandAlias::SUCCESS; } }