Skip to content

Commit

Permalink
Merge pull request #1033 from uasoft-indonesia/task/v3/address
Browse files Browse the repository at this point in the history
add address badaso users
  • Loading branch information
rizkiheryandi authored Sep 28, 2023
2 parents d7d6616 + 84d9f37 commit 9195638
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 34 deletions.
10 changes: 10 additions & 0 deletions src/Controllers/BadasoAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,18 @@ public function register(Request $request)
'phone' => 'required|numeric|min:6',
'email' => 'required|string|email|max:255|unique:Uasoft\Badaso\Models\User',
'password' => 'required|string|min:6|confirmed',
'address' => 'required|string|max:255',
'gender' => 'required|string',
]);

$user = User::create([
'name' => $request->get('name'),
'username' => $request->get('username'),
'phone' => $request->get('phone'),
'address' => $request->get('address'),
'email' => $request->get('email'),
'password' => Hash::make($request->get('password')),
'gender' => $request->get('gender'),
]);

$role = $this->getCustomerRole();
Expand Down Expand Up @@ -522,14 +526,20 @@ public function updateProfile(Request $request)
'name' => 'required|string|max:255',
'username' => "required|string|max:255|alpha_num|unique:Uasoft\Badaso\Models\User,username,{$user_id}",
'avatar' => 'nullable',
'phone' => 'nullable',
'address' => 'nullable',
'gender' => 'nullable',
]);

$user = User::find($user->id);

$user->name = $request->name;
$user->username = $request->username;
$user->phone = $request->phone;
$user->address = $request->address;
$user->avatar = $request->avatar;
$user->additional_info = $request->additional_info;
$user->gender = $request->gender;
$user->save();

DB::commit();
Expand Down
12 changes: 12 additions & 0 deletions src/Controllers/BadasoUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ public function edit(Request $request)
'username' => "required|string|max:255|alpha_num|unique:Uasoft\Badaso\Models\User,username,{$request->id}",
'name' => 'required',
'avatar' => 'nullable',
'phone' => 'nullable',
'address' => 'nullable',
'gender' => 'nullable',
]);

$user = User::find($request->id);
$old_user = $user->toArray();
$user->name = $request->name;
$user->username = $request->username;
$user->phone = $request->phone;
$user->address = $request->address;
$user->email = $request->email;
$user->avatar = $request->avatar;
$user->gender = $request->gender;
$user->additional_info = $request->additional_info;
if ($request->password && $request->password != '') {
$user->password = Hash::make($request->password);
Expand Down Expand Up @@ -105,13 +111,19 @@ public function add(Request $request)
'name' => 'required|string|max:255',
'username' => 'required|string|max:255|alpha_num|unique:Uasoft\Badaso\Models\User,username',
'avatar' => 'nullable',
'phone' => 'required|numeric|min:6',
'address' => 'nullable',
'gender' => 'required|string',
]);

$user = new User();
$user->name = $request->name;
$user->username = $request->username;
$user->phone = $request->phone;
$user->address = $request->address;
$user->email = $request->email;
$user->avatar = $request->avatar;
$user->gender = $request->gender;
$user->additional_info = $request->additional_info;
$user->password = Hash::make($request->password);
if ($request->email_verified) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddAddressToBadasoUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table(config('badaso.database.prefix').'users', function (Blueprint $table) {
$table->text('address')->nullable()->after('phone');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table(config('badaso.database.prefix').'users', function (Blueprint $table) {
$table->dropColumn('address');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddGenderToBadasoUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table(config('badaso.database.prefix').'users', function (Blueprint $table) {
$table->enum('gender', ['man', 'woman'])->nullable()->after('additional_info');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table(config('badaso.database.prefix').'users', function (Blueprint $table) {
$table->dropColumn('gender');
});
}
}
2 changes: 2 additions & 0 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function __construct(array $attributes = [])
'email',
'password',
'avatar',
'address',
'gender',
'additional_info',
'last_sent_token_at',
];
Expand Down
2 changes: 1 addition & 1 deletion src/resources/badaso/components/BadasoSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</template>

<script>
import * as DOMPurify from 'dompurify';
import DOMPurify from 'dompurify';
export default {
name: "BadasoSelect",
components: {},
Expand Down
40 changes: 40 additions & 0 deletions src/resources/badaso/lang/modules/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ export default {
name: "Name",
username: "Username",
phone: "Phone",
address: "Address",
email: "Email",
password: "Password",
passwordConfirmation: "Password Confirmation",
gender: "Gender",
},
button: "Register",
existingAccount: {
text: "Do you have an account?",
link: "Login",
},
gender: {
man: "Man",
woman: "Woman",
},
},

forgotPassword: {
Expand Down Expand Up @@ -125,6 +131,9 @@ export default {
newPasswordConfirmation: "New Password Confirmation",
name: "Name",
avatar: "Avatar",
phone: "Phone Number",
address: "Address",
gender: "Gender",
additionalInfo: "Additional info(optional)",
token: "Verification Code",
buttons: {
Expand Down Expand Up @@ -652,6 +661,14 @@ export default {
title: "Username",
placeholder: "Username",
},
phone: {
title: "Phone Number",
placeholder: "Phone Number",
},
address: {
title: "Address",
placeholder: "Address",
},
email: {
title: "Email",
placeholder: "Email",
Expand All @@ -668,6 +685,10 @@ export default {
title: "Avatar",
placeholder: "Avatar",
},
gender: {
title: "Gender",
placeholder: "Gender",
},
additionalInfo: {
title: "Additional Info (JSON)",
placeholder: "Additional Info (JSON)",
Expand All @@ -687,6 +708,18 @@ export default {
title: "Username",
placeholder: "Username",
},
phone: {
title: "Phone Number",
placeholder: "Phone Number",
},
address: {
title: "Address",
placeholder: "Address",
},
gender: {
title: "Gender",
placeholder: "Gender",
},
email: {
title: "Email",
placeholder: "Email",
Expand Down Expand Up @@ -716,6 +749,9 @@ export default {
avatar: "Avatar",
name: "Name",
username: "Username",
phone: "Phone Number",
address: "Address",
gender: "Gender",
email: "Email",
additionalInfo: "Additional Info",
emailVerified: "Is Email Verified",
Expand All @@ -733,6 +769,10 @@ export default {
text: "Roles has been set",
},
},
gender: {
man: "Man",
woman: "Woman",
},
},

role: {
Expand Down
42 changes: 41 additions & 1 deletion src/resources/badaso/lang/modules/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export default {
field: {
name: "Nama",
username: "Username",
phone: "Phone",
phone: "No Telp/Hp",
address: "Alamat",
gender: "Jenis Kelamin",
email: "Email",
password: "Kata sandi",
passwordConfirmation: "Konfirmasi kata sandi",
Expand All @@ -50,6 +52,10 @@ export default {
text: "Sudah mempunyai akun?",
link: "Masuk",
},
gender: {
man: "Laki-laki",
women: "Perempuan",
},
},

forgotPassword: {
Expand Down Expand Up @@ -125,6 +131,9 @@ export default {
newPasswordConfirmation: "New Password Confirmation",
name: "Name",
avatar: "Avatar",
phone: "No Telp/Hp",
address: "Alamat",
gender: "Jenis Kelamin",
additionalInfo: "Additional info(optional)",
token: "Verification Code",
buttons: {
Expand Down Expand Up @@ -648,6 +657,18 @@ export default {
title: "Username",
placeholder: "Username",
},
phone: {
title: "No Telp/Hp",
placeholder: "No Telp/Hp",
},
address: {
title: "Alamat",
placeholder: "Alamat",
},
gender: {
title: "Jenis Kelamin",
placeholder: "Jenis Kelamin",
},
password: {
title: "Kata sandi",
placeholder: "Kata sandi",
Expand Down Expand Up @@ -679,6 +700,18 @@ export default {
title: "Username",
placeholder: "Username",
},
phone: {
title: "No Telp/Hp",
placeholder: "No Telp/Hp",
},
address: {
title: "Alamat",
placeholder: "Alamat",
},
gender: {
title: "Jenis Kelamin",
placeholder: "Jenis Kelamin",
},
email: {
title: "Email",
placeholder: "Email",
Expand Down Expand Up @@ -708,7 +741,10 @@ export default {
avatar: "Avatar",
name: "Nama",
username: "Username",
phone: "No Telp/Hp",
address: "Alamat",
email: "Email",
gender: "Jenis Kelamin",
additionalInfo: "Info Tambahan",
emailVerified: "Email Diverifikasi",
},
Expand All @@ -725,6 +761,10 @@ export default {
text: "Wewenang telah ditetapkan",
},
},
gender: {
man: "Laki-laki",
women: "Perempuan",
},
},

role: {
Expand Down
Loading

0 comments on commit 9195638

Please sign in to comment.