'', 'number' => '', ]; /** @var array */ public $address = [ 'street' => '', 'number' => '', 'complement' => '', 'neighbourhood' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country' => '', ]; /** @var array */ public $profile = [ 'gender' => '', 'occupation' => '', 'scholarity' => '', 'phone' => '', 'secondary_emails' => '', 'website' => '', 'social' => '', 'expectation' => '', 'bike_use' => '', 'org_participation' => '', 'bike_activities' => '', 'comments' => '', 'ucb_comments' => '', ]; /** @var string */ public $email = ''; /** @var string */ public $discussion = ''; /** @var int */ public $contribution = null; public function updated($field) { $this->validateOnly($field, [ 'email' => ['email', 'unique:users'], 'birthday' => ['date_format:d/m/Y'], 'address.street' => ['string'], 'address.number' => ['string'], 'address.complement' => ['string'], 'address.neighbourhood' => ['string'], 'address.city' => ['string'], 'address.state' => ['string'], 'address.postcode' => ['string'], 'address.country' => ['string'], 'profile.gender' => ['string', 'in:male,female,other'], 'profile.occupation' => ['string'], 'profile.scholarity' => ['string', 'in:primary-school,high-school,bachelor,master,phd'], 'profile.phone' => ['string'], 'profile.secondary_emails' => ['string'], 'profile.website' => ['string'], 'profile.social' => ['string'], 'profile.expectation' => ['string'], 'profile.bike_use' => ['string'], 'profile.org_participation' => ['string'], 'profile.bike_activities' => ['string'], 'profile.comments' => ['string'], 'profile.ucb_comments' => ['string'], 'document.type' => ['string', 'in:cpf,identity,passport'], 'document.number' => ['string'], 'discussion' => ['string', 'in:all,daily,occasional'], 'contribution' => ['numeric'], ]); } public function register() { $this->validate([ 'name' => ['required'], 'birthday' => ['required', 'date_format:d/m/Y'], 'email' => ['required', 'email', 'unique:users'], 'address.street' => ['required', 'string'], 'address.number' => ['required', 'string'], 'address.complement' => ['required', 'string'], 'address.neighbourhood' => ['required', 'string'], 'address.city' => ['required', 'string'], 'address.state' => ['required', 'string'], 'address.postcode' => ['required', 'string'], 'address.country' => ['required', 'string'], 'profile.gender' => ['required', 'string', 'in:male,female,other'], 'profile.occupation' => ['required', 'string'], 'profile.scholarity' => ['required', 'string', 'in:primary-school,high-school,bachelor,master,phd'], 'profile.phone' => ['required', 'string'], 'profile.secondary_emails' => ['required', 'string'], 'profile.website' => ['nullable', 'string'], 'profile.social' => ['nullable', 'string'], 'profile.expectation' => ['nullable', 'string'], 'profile.bike_use' => ['nullable', 'string'], 'profile.org_participation' => ['nullable', 'string'], 'profile.bike_activities' => ['nullable', 'string'], 'profile.comments' => ['nullable', 'string'], 'profile.ucb_comments' => ['nullable', 'string'], 'document.type' => ['required', 'string', 'in:cpf,identity,passport'], 'document.number' => ['required', 'string'], 'discussion' => ['required', 'string', 'in:all,daily,occasional'], 'contribution' => ['required', 'numeric'], ]); $user = new User([ 'name' => $this->name, 'birthday' => Carbon::createFromFormat('d/m/Y', $this->birthday), 'address' => $this->address, 'profile' => $this->profile, 'document' => $this->document, 'discussion' => $this->discussion, 'contribution' => $this->contribution, 'email' => $this->email, ]); $user->user_category_id = UserCategory::where('key', 'individual')->first()->id; $user->user_nature_id = UserNature::where('key', 'individual')->first()->id; $user->user_type_id = UserType::where('key', 'individual')->first()->id; $user->save(); Auth::login($user, true); redirect(route('home')); } public function render() { return view('livewire.auth.register.individual'); } }