Dear all,
In another Laravel project, without having Spark implemented, I also create a new record in the database table 'organisations' when creating a new User. I do this by using the following code in my RegisterController file:
public function create(array $data)
{
$organisation = new Organisation;
$organisation->profile_id = $data['profile_id'];
$organisation->name = $data['org_name'];
$organisation->city = $data['org_city'];
$organisation->state = $data['org_state'];
$organisation->country = $data['org_country'];
$organisation->website = $data['org_website'];
$organisation->email = $data['org_email'];
$organisation->phone = $data['org_phone'];
$organisation->save();
return User::create([
'organisation_id' => $organisation->id,
'name' => '' . $data['name'],
'function' => $data['function'],
'email' => $data['email'],
'phone' => $data['phone'],
'mobile' => $data['mobile'],
'password' => bcrypt($data['password']),
'trial_ends_at' => Carbon::now()->addDays(14)
]);
}
Works like a charm. I tried to implement the same method in a project that does use Spark, but unfortunately, this method does not seem to work here. When registering a new user through the registration form, the form returns that 'an error has occurred'. There aren't more specific details.
I tried implementing the code above within Spark::createUsersWith in the SparkServiceProvider, but that didn't make any difference.
Who could help me back on track here?
Thanks! Vincent