Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JakeDeWitt's avatar

What event can I listen for in Laravel Spark for when a user signs up for a free TEAM trial?

To be clear, this is probably not the TeamSubscribed event because the team is not yet on a subscription. I am looking for when a trial is started- I need to run some code.

0 likes
6 replies
JakeDeWitt's avatar

This does not seem very effective for all cases. In the future we may add more types of subscriptions and trials. So if I base it off of when the team is created, that may be unsafe.

ejdelmonico's avatar

Then I would suggest creating your own event and listener. That should be adaptable to your needs.

JakeDeWitt's avatar

Without asking you to spend too much time on this, how would I go about that? I know that I can fire an event anywhere and the listener will pick up on it, but I need it to be connected to the point of a free trial being registered, which is a Spark thing.

I am not new to Laravel, but I'm not too familiar with the events and listeners portion.

ejdelmonico's avatar

Yes, That is why I suggested listening for one of the initial events. That way you know its a new registration. The trick is to decide how you want to fire the event if it meets your qualifications. The event itself should be suited to executing small bits of code.

The only events that Spark for teams provides are listed in the docs. I think the applicable to you would be this event: Teams\Subscription\TeamSubscribed. You can create a simple Laravel listener which decides if the team is on a trial and then fires an event to run your code. If not, it just passes to next. You can use an event subscriber as well to fine grain the event handling. Also, Spark::trialDays() may help with the listener determination.

A sample listener:

<?php

namespace app\Listeners;

use App\User;
use App\Notifications\UserDidRegister;
use Laravel\Spark\Events\Subscription\UserSubscribed;

class CreatedNewUser
{
    public $user;

    /**
     * Create the event listener.
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Handle the event.
     *
     * @param UserSubscribed $event
     */
    public function handle(UserSubscribed $event)
    {
        $user = $event->user;
        $user->notify(new UserDidRegister($user));
    }
}
JakeDeWitt's avatar

I have already tried the TeamSubscribed event and it never fired when the trial began. I believe it only fires when a real subscription is made.

Please or to participate in this conversation.