Building out a project in Laravel Spark and need to add a couple of extra fields to the Teams.
I am offering a free trial, the fields on the registration page are the usual user fields and also the team name. I need to also add a 'branch_name' and 'contact_email' for the teams on registration.
I have modified my view to have these fields, added the fields to my app.js:
Spark.forms.register = {
team_branch: '',
contact_email: ''
};
In my booted method in Spark Service Provider I have added:
Spark::validateUsersWith(function () {
return [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'vat_id' => 'max:50|vat_id',
'terms' => 'required|accepted',
'branch_name' => 'required',
'contact_number' => 'required',
'team_email' => 'required'
];
});
Spark::swap('TeamRepository@create', function($user, array $data)
{
$attributes = [
'owner_id' => $user->id,
'name' => $data['name'],
'branch_name' => $data['branch_name'],
'trial_ends_at' => Carbon::now()->addDays(Spark::teamTrialDays()),
];
return Spark::team()->forceCreate($attributes);
});
The API response is validating the extra fields correctly, but the $data array passed into the create method of the TeamRepository doesn't contain the extra fields.
I cannot make the link of where to go next to get the extra fields being passed into that method.
Thanks.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sB71v4
via IFTTT
Aucun commentaire:
Enregistrer un commentaire