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

clat23's avatar

Registration: "Something went wrong. Please try again or contact customer support."

I have followed this documentation: https://spark.laravel.com/docs/3.0/adding-registration-fields

Here's my code:

register-common-form.blade.php:

    <!-- Timezone -->
    <?php require(app_path().'/Includes/timezones.php'); ?>
    <div class="form-group" :class="{'has-error': registerForm.errors.has('timezone')}">
        <label class="col-md-4 control-label">Timezone</label>

        <div class="col-md-6">
            <select class="form-control" name="timezone" v-model="registerForm.timezone">
            @foreach ($timezones as $formTimezone => $utc)
                <option value="{{ $formTimezone }}">{{ $utc }}</option>
            @endforeach
            </select>

            <span class="help-block" v-show="registerForm.errors.has('timezone')">
                @{{ registerForm.errors.get('timezone') }}
            </span>
        </div>
    </div>

app.js


/*
 |--------------------------------------------------------------------------
 | Laravel Spark Bootstrap
 |--------------------------------------------------------------------------
 |
 | First, we will load all of the "core" dependencies for Spark which are
 | libraries such as Vue and jQuery. This also loads the Spark helpers
 | for things such as HTTP calls, forms, and form validation errors.
 |
 | Next, we'll create the root Vue application for Spark. This will start
 | the entire application and attach it to the DOM. Of course, you may
 | customize this script as you desire and load your own components.
 |
 */

require('spark-bootstrap');

require('./components/bootstrap');

Spark.forms.register = {
    timezone: ''
};

var app = new Vue({
    mixins: [require('spark')]
});

SparkServiceProvider.php

<?php

namespace App\Providers;

use Laravel\Spark\Spark;
use Laravel\Spark\Providers\AppServiceProvider as ServiceProvider;

class SparkServiceProvider extends ServiceProvider
{
    /**
     * Your application and company details.
     *
     * @var array
     */
    protected $details = [
        'vendor' => 'Your Company',
        'product' => 'Your Product',
        'street' => 'PO Box 111',
        'location' => 'Your Town, NY 12345',
        'phone' => '555-555-5555',
    ];

    /**
     * The address where customer support e-mails should be sent.
     *
     * @var string
     */
    protected $sendSupportEmailsTo = null;

    /**
     * All of the application developer e-mail addresses.
     *
     * @var array
     */
    protected $developers = [
        //
    ];

    /**
     * Indicates if the application will expose an API.
     *
     * @var bool
     */
    protected $usesApi = true;

    /**
     * Finish configuring Spark for the application.
     *
     * @return void
     */
    public function booted()
    {
        Spark::useStripe()->noCardUpFront()->trialDays(10);

        Spark::freePlan()
            ->features([
                'First', 'Second', 'Third'
            ]);

        Spark::plan('Basic', 'myapp-test-1')
            ->price(10)
            ->features([
                'First', 'Second', 'Third'
            ]);

        Spark::validateUsersWith(function () {
            return [
                'name' => 'required|max:255',
                'email' => 'required|email|max:255|unique:users',
                'timezone' => 'required|max:50',
                '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'],
              'timezone' => $data['timezone'],
              'password' => bcrypt($data['password']),
              'last_read_announcements_at' => Carbon::now(),
              'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays()),
          ])->save();
          return $user;
        });
    }
}

I have added

$table->string('timezone')->nullable();

to my create_users_table migration

I have updated my Users.php model to add timezone:

    protected $fillable = [
        'name',
        'email',
        'timezone',
    ];

When I attempt to register a new user with my app, I get the following error: "Something went wrong. Please try again or contact customer support."

What did I miss?

0 likes
4 replies
clat23's avatar

It's also worth noting that when I remove from SparkServiceProviders.php the following code;

Spark::createUsersWith(function ($request) {
          $user = Spark::user();
          $data = $request->all();
          $user->forceFill([
              'name' => $data['name'],
              'email' => $data['email'],
              'timezone' => $data['timezone'],
              'password' => bcrypt($data['password']),
              'last_read_announcements_at' => Carbon::now(),
              'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays()),
          ])->save();
          return $user;
        });

No error on user registration. But the user does not receive the timezone in the user's table in the database.

clat23's avatar

Here's the error thrown in larvel.log:

[2017-02-04 03:45:48] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Providers\Carbon' not found in /home/vagrant/Code/myapp/app/Providers/SparkServiceProvider.php:85

clat23's avatar
clat23
OP
Best Answer
Level 3

Ok so I added

Use Carbon\Carbon;

to SparkServiceProvider.php and it worked. Does the Spark Documentation need to be updated?

Does the Laravel Spark Framework need to be updated to have this on fresh install?

mstrauss's avatar

Exact same issue and yes, it seems as though you need to at the "Use Carbon\Carbon;" for it to work properly.

And I don't think the Spark Framework needs to be updated. Just the example case on how to add a new field to the registration form. It should mention the need to add the Carbon namespace.

Please note, I just did a fresh install of Spark and the registration works fine out of the box. It's only when you add new fields and must register the forceFill method under the booted method of the Spark Service provider that these issues arise.

Please or to participate in this conversation.