laravellaravel-spark

Laravel Spark referToTeamAs method is not working


In my SparkServiceProvider.php where you set up your spark configuration and plans, I have Spark::referToTeamAs('group');

When I visit /missing-group I'm getting a 404 error because var_dumping $teamString in /spark/src/Http/routes.php is showing team and not group. So it looks like my setting is not catching before that routes file is used.

Is there any way to set the teamString before that routes file is called? Like changing the order of the service providers or something?

I'm not really sure where to start. Thanks in advance!

App\Providers\SparkServiceProvider

...

/**
 * Finish configuring Spark for the application.
 *
 * @return void
 */
public function booted()
{
    Spark::collectsBillingAddress();
    Spark::afterLoginRedirectTo('/dashboard');
    Spark::referToTeamAs('group');        

    Spark::useStripe()
        ->noProrate()
        ->noAdditionalTeams();

    Spark::plan('Individual', 'stripe-individual-ticket')
        ->price(300)
        ->features(['First', 'Second', 'Third'])
        ->yearly();

    Spark::teamPlan('Group', 'stripe-group-ticket')
        ->price(300)
        ->features(['First', 'Second', 'Third'])
        ->yearly();
}

...

Solution

  • From the docs:

    Be sure to call this method in the register method of your service provider, as Spark will not function correctly if it is called in the booted method. Additionally, make sure you pass the singular, lowercase form of the word.

    So instead of

    public function booted()
    {
        ...
        Spark::referToTeamAs('group');
        ...
    

    You'll want

    public function register()
    {
        ...
        Spark::referToTeamAs('group');
        ...