Sep 28th, 2023 08:57 AM

Hi Guys,

I am busy finalising my product using Wave. However I have run into something I have been avoiding for a while now.

I need to implement my licensing mechanism. So what I want to do is leverage the Roles functionality of Wave/Voyager whereby I can say how many entries a user is allowed to save in the data table.

To give an example, I want an option to say how many alerts a user can create in the Pro plan.

Hope this makes sense?


Sep 29th, 2023 02:45 AM

Hey Brian!

One way of doing this would be to extend add an extra column to the plans table called max_alerts for example. That will indicate how many alerts a user is allowed to have with the plan that they've subscribed to.

Then before a user saves a new alert, you can check the number of alerts they've already created against the maximum allowed by their plan, with something like this:

public function canCreateAlert(User $user)
    // Get the maximum allowed alerts for the user's plan
    $maxAlerts = $user->plan->max_alerts;

    // Count the number of alerts the user has already created
    $currentAlertCount = $user->alerts()->count();

    return $currentAlertCount < $maxAlerts;

Here, I'm assuming you have a relationship method alerts() on the User model that retrieves the alerts associated with a user, but if not you could change the logic to match your models.

After that, when a user tries to create a new alert, you can use the above function to check if they're allowed:

public function store(Request $request)
    $user = auth()->user();

    if (!$this->canCreateAlert($user)) {
        return redirect()->back()->withErrors(['error' => 'You have reached your alert limit. Upgrade to create more alerts.']);

    // Logic to create and save the alert...

    return redirect()->route('alerts.index')->withSuccess('Alert created successfully!');

If a user tries to create an alert beyond their limit, you can prompt them to upgrade to a higher plan. This can be done in the view layer by showing a message or a button that redirects them to the upgrade page.

Hope that this helps!




Sep 29th, 2023 07:28 AM

Hey Bobby,

Yup that would do the trick nicely. Thanks!

How would I be able to specify the number of alerts in the Role page when adding a new role?

I want to edit the Role edit page but cannot seem to be able to find it.


Sep 30th, 2023 06:13 AM

Best Answer

Hi there,

If you've made a change to the roles table, then you will have to go to your BREAD for that tabled and just save it. That way it will refresh the BREAD for the roles table and include any new columns that you've added.

Let me know how it goes.


Sep 30th, 2023 07:06 AM

Hey Bobby,

You are a legend!

Thanks dude.


Sep 30th, 2023 11:40 AM

No problem at all! Happy to help!