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

jpeterson579's avatar

Add additional registration field to spark error

Hi all, So I followed the documentation exactly https://spark.laravel.com/docs/3.0/adding-registration-fields#introduction and get the following error when trying to add a new field to the registration form for my laravel spark app.

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Providers\Carbon' not found in /Applications/MAMP/htdocs/laravel53/app/Providers/SparkServiceProvider.php:74

Any ideas on how to fix? Anyone else experience this?

0 likes
4 replies
ejdelmonico's avatar

According to the error message, it is something in your booted() method in the service provider. If you were trying to use a Carbon instance, I think you have the wrong import.

jpeterson579's avatar

@ejdelmonico but how could that be? I have the most recent laravel and spark versions and followed the docs exactly? Is the documentation wrong then?

SparkServiceProvider

public function booted()
{
    Spark::validateUsersWith(function () {
        return [
            'name' => 'required|max:255',
            'age' => 'required|integer|min:1',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
            'vat_id' => 'max:50|vat_id',
            'terms' => 'required|accepted',
        ];
    });
    Spark::createUsersWith(function ($request) {
        $user = Spark::user();
    
        $data = $request->all();
    
        $user->forceFill([
            'name' => $data['name'],
            'email' => $data['email'],
            'age' => $data['age'],
            'password' => bcrypt($data['password']),
            'last_read_announcements_at' => Carbon::now(),
            'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays()),
        ])->save();
    
        return $user;
    });
    
    Spark::useStripe()->noCardUpFront();
    
    // Spark::collectBillingAddress();
    
    Spark::freePlan()
        ->features([
            'First', 'Second', 'Third'
        ]);

    Spark::plan('Monthly', 'spark-monthly-1')
        ->trialDays(31)
        ->price(10)
        ->features([
            'First', 'Second', 'Third'
        ]);
    
    Spark::plan('Annual', 'spark-annual-1')
        ->trialDays(31)
        ->price(100)
        ->yearly()
        ->features([
            'First', 'Second', 'Third'
        ]);
}
ejdelmonico's avatar
Level 53

Ok, are you importing Carbon\Carbon? I see you are using a Carbon date as identified in the error message.

jpeterson579's avatar

guess it helps if i put

use Carbon/Carbon;

at the top.... :)

Please or to participate in this conversation.