diff --git a/app/Http/Livewire/Auth/Register/Individual.php b/app/Http/Livewire/Auth/Register/Individual.php index 17e7dcb..c7ffb78 100644 --- a/app/Http/Livewire/Auth/Register/Individual.php +++ b/app/Http/Livewire/Auth/Register/Individual.php @@ -19,14 +19,80 @@ class Individual extends Component /** @var string */ public $birthday = ''; + /** @var array */ + public $document = [ + 'type' => '', + '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'], ]); } @@ -36,12 +102,42 @@ class Individual extends Component '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, - 'email' => $this->email, '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; diff --git a/app/User.php b/app/User.php index 172456f..c40c78b 100644 --- a/app/User.php +++ b/app/User.php @@ -16,7 +16,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'birthday' + 'name', 'email', 'password', 'birthday', 'document' ]; /** @@ -35,6 +35,8 @@ class User extends Authenticatable */ protected $casts = [ 'birthday' => 'date', + 'document' => 'array', + 'profile' => 'array', ]; /** diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 1360f55..52abcb5 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -25,12 +25,12 @@ class CreateUsersTable extends Migration $table->foreignId('user_type_id'); // $table->string('avatar')->nullable(); $table->date('birthday'); -// $table->json('document')->nullable(); + $table->json('document')->nullable(); // $table->json('address'); // $table->string('phone'); -// $table->string('discussion'); + $table->string('discussion'); // $table->integer('donation')->nullable(); -// $table->json('profile'); + $table->json('profile'); $table->rememberToken(); $table->timestamps(); diff --git a/resources/lang/pt-BR/users.php b/resources/lang/pt-BR/users.php index 3244987..1d88d85 100644 --- a/resources/lang/pt-BR/users.php +++ b/resources/lang/pt-BR/users.php @@ -4,6 +4,37 @@ return [ 'attributes' => [ 'name' => 'Nome completo', 'birthday' => 'Data de nascimento', + 'document' => [ + 'type' => 'Tipo de documento', + 'number' => 'Nº do documento', + ], + 'address' => [ + 'street' => 'Rua', + 'number' => 'Número', + 'complement' => 'Complemento', + 'neighbourhood' => 'Bairro', + 'city' => 'Cidade', + 'state' => 'Estado (UF)', + 'postcode' => 'CEP', + 'country' => 'País', + ], + 'profile' => [ + 'gender' => 'Você se identifica como', + 'occupation' => 'Ramo de atuação', + 'scholarity' => 'Escolaridade', + 'phone' => 'Telefone', + 'secondary_emails' => 'E-mails secundários', + 'website' => 'Sítio eletrônico', + 'social' => 'Rede social', + 'expectation' => 'Expectativa em relação à UCB', + 'bike_use' => 'Uso da bicicleta', + 'org_participation' => 'Participação em organização de ciclistas', + 'bike_activities' => 'Atividades pró-ciclomobilidade', + 'comments' => 'Observações', + 'ucb_comments' => 'Observações UCB', + ], 'email' => 'E-mail principal', + 'discussion' => 'Participação no grupo de comunicação', + 'contribution' => 'Contribuição financeira', ], ]; diff --git a/resources/views/components/input/group.blade.php b/resources/views/components/input/group.blade.php index 6be5ce0..759379f 100644 --- a/resources/views/components/input/group.blade.php +++ b/resources/views/components/input/group.blade.php @@ -4,7 +4,7 @@ 'error' => false, ]) -