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?