Design – Designing a Ticketing System with User and Admin Functionalities

ArchitecturedesignlaravelPHP

I am designing a simple ticketing system in Laravel 4. The system will simply allow a User to create a ticket, and an Administrator to answer it.

The User will be able to:

  • View a list of his tickets.
  • Create a new ticket.
  • View the replies to one of his own ticket.
  • Add a reply to a one of his own ticket.
  • Close a one of his own ticket.
  • Perform the above tasks via the url www.example.com/support

The Administrator will be able to:

  • View a list of all tickets.
  • Cannot create a new ticket.
  • View the replies to any ticket.
  • Add a reply to any ticket.
  • Close any ticket.
  • Perform the above tasks via the url www.example.com/admin/support

In other words, a User and Administrator can perform very similar, but different functionality. What are ways that I can design this system to reduce the amount of copying and pasting that must be done?

So far, I have came up with two possibilities.

  1. Create two sets of Routes with two Controllers – one for the user and one for the admin. Copy and paste most of the logic between the Controllers, but changing a few variables so that users can only see his own tickets. Both Controllers share the same Views and Model. Add in an additional check in the Views so that the admin do not see a button to create a new ticket.

    The down side of this is that I have to put logic in the Views in order to hide certain things from the admin, and other things from the user. I am also copying and pasting code between controllers.

  2. Create two sets of Routes but use the same Controller. Use if statements in the Controller to show different Views depending on whether it is a User or an Administrator.

    However, now I am copying and pasting code between views. Having two different set of logic in the same Controller may be a bit confusing as well.

Is there a better way to go about this?

Best Answer

Write two different UIs.

Really. I work on exactly such a system every day, and the user experience for your User and Administrator personae are completely different. They're different because the needs of those users are completely different.

Administrators will spend large parts of their day with your ticket list open in front of them, interacting with tickets on and off all day. The Administrator UI needs to be efficient and powerful, as befits the primary application used by its humans.

Users will go to your site once in a rare while, create a ticket, check a ticket, and leave. The User UI needs to be simple to understand and navigate, and to require almost no thought to use, as befits a rarely used application.

Related Topic