PHP

Enhancements to Plan Management in Breniapp

Introduction

The Breniapp project recently underwent some improvements focused on enhancing the user experience and ensuring accurate data retrieval, specifically within the plan upgrade process and sidebar behavior.

Sidebar Transition Adjustment

Previously, the sidebar separator included an animation during collapsing, which caused a slight delay and visual inconsistency. The update removes this transition, providing a more immediate and responsive feel when the sidebar is collapsed or expanded.

Plan Resolution by Slug

A critical fix was implemented in the upgrade modal concerning how plans are resolved. Originally, the modal used the billing_period attribute to identify plans. This approach proved problematic when multiple plans shared the same billing_period, leading to the Premium plan not appearing for users. To address this, the plan resolution logic was updated to use the slug attribute, which is unique for each plan, ensuring accurate plan identification and display.

class PlanService
{
    public function resolvePlanBySlug(string $slug): ?Plan
    {
        return Plan::where('slug', $slug)->first();
    }

    public function getAvailablePlans(): Collection
    {
        return Plan::all();
    }
}

// Usage in Upgrade Modal
$plan = (new PlanService())->resolvePlanBySlug($slug);

if ($plan) {
    // Display plan details
} else {
    // Handle plan not found scenario
}

Benefits

  • Improved User Experience: The immediate sidebar collapse provides a more responsive interface.
  • Accurate Plan Display: Resolving plans by slug ensures the correct plans are always displayed in the upgrade modal.
  • Robustness: Using a unique identifier like slug reduces the risk of errors caused by non-unique attributes.

Conclusion

These updates to Breniapp contribute to a smoother and more reliable user experience. Switching to a unique identifier such as a slug ensures data accuracy and prevents potential issues arising from duplicate values. These refinements are crucial for maintaining a high-quality application.

Enhancements to Plan Management in Breniapp
GERARDO RUIZ

GERARDO RUIZ

Author

Share: