add display_name support
This commit is contained in:
@@ -153,8 +153,9 @@ class UserController extends ApiController
|
||||
'last_name' => $request->input('last_name'),
|
||||
'username' => $request->input('username'),
|
||||
'email' => $request->input('email'),
|
||||
'phone' => $request->input('phone'),
|
||||
'password' => Hash::make($request->input('password'))
|
||||
'phone' => $request->input('phone', ''),
|
||||
'password' => Hash::make($request->input('password')),
|
||||
'display_name' => $request->input('display_name', $request->input('username')),
|
||||
]);
|
||||
|
||||
$code = $user->codes()->create([
|
||||
|
||||
@@ -16,6 +16,7 @@ class UserRegisterRequest extends FormRequest
|
||||
return [
|
||||
'first_name' => 'required|string|max:255',
|
||||
'last_name' => 'required|string|max:255',
|
||||
'display_name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255',
|
||||
'username' => 'required|string|min:4|max:255|unique:users',
|
||||
'password' => 'required|string|min:8',
|
||||
|
||||
@@ -17,6 +17,7 @@ class UserRequest extends BaseRequest
|
||||
'username' => 'required|string|max:255|min:4|unique:users',
|
||||
'first_name' => 'required|string|max:255|min:2',
|
||||
'last_name' => 'required|string|max:255|min:2',
|
||||
'display_name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255',
|
||||
'phone' => ['string', 'regex:/^(\+|00)?[0-9][0-9 \-\(\)\.]{7,32}$/'],
|
||||
'email_verified_at' => 'date'
|
||||
@@ -46,6 +47,7 @@ class UserRequest extends BaseRequest
|
||||
],
|
||||
'first_name' => 'string|max:255|min:2',
|
||||
'last_name' => 'string|max:255|min:2',
|
||||
'display_name' => 'string|max:255|min:2',
|
||||
'email' => 'string|email|max:255',
|
||||
'phone' => ['nullable','regex:/^(\+|00)?[0-9][0-9 \-\(\)\.]{7,32}$/'],
|
||||
'password' => 'string|min:8'
|
||||
|
||||
@@ -31,6 +31,7 @@ class User extends Authenticatable implements Auditable
|
||||
'email',
|
||||
'phone',
|
||||
'password',
|
||||
'display_name',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -66,6 +67,15 @@ class User extends Authenticatable implements Auditable
|
||||
'permissions'
|
||||
];
|
||||
|
||||
/**
|
||||
* The default attributes.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $attributes = [
|
||||
'phone' => '',
|
||||
];
|
||||
|
||||
|
||||
// public function getPermissionsAttribute() {
|
||||
// return $this->permissions()->pluck('permission')->toArray();
|
||||
|
||||
@@ -20,15 +20,22 @@ class UserFactory extends Factory
|
||||
$faker = \Faker\Factory::create();
|
||||
$faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker));
|
||||
|
||||
$username = $faker->unique()->userNameWithMinLength(6);
|
||||
$first_name = $faker->firstName();
|
||||
$last_name = $faker->lastName();
|
||||
|
||||
$display_name = $faker->randomElement([$username, $first_name . ' ' . $last_name]);
|
||||
|
||||
return [
|
||||
'username' => $faker->unique()->userNameWithMinLength(6),
|
||||
'first_name' => $faker->firstName(),
|
||||
'last_name' => $faker->lastName(),
|
||||
'username' => $username,
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'email' => $faker->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'phone' => $faker->phoneNumber(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
'display_name' => $display_name,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ import { useReCaptcha } from "vue-recaptcha-v3";
|
||||
import SMButton from "../components/SMButton.vue";
|
||||
import SMFormCard from "../components/SMFormCard.vue";
|
||||
import SMForm from "../components/SMForm.vue";
|
||||
import SMInput from "../depreciated/SMInput-old.vue";
|
||||
import SMInput from "../components/SMInput.vue";
|
||||
import { api } from "../helpers/api";
|
||||
import { Form, FormControl } from "../helpers/form";
|
||||
import {
|
||||
@@ -145,6 +145,7 @@ const handleSubmit = async () => {
|
||||
phone: form.controls.phone.value,
|
||||
username: form.controls.username.value,
|
||||
password: form.controls.password.value,
|
||||
display_name: form.controls.username.value,
|
||||
captcha_token: captcha,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -92,6 +92,7 @@ class UsersApiTest extends TestCase
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'username' => 'johndoe',
|
||||
'display_name' => 'jackdoe',
|
||||
'email' => 'johndoe@example.com',
|
||||
'password' => 'password',
|
||||
];
|
||||
@@ -110,6 +111,7 @@ class UsersApiTest extends TestCase
|
||||
'first_name' => 'Jack',
|
||||
'last_name' => 'Doe',
|
||||
'username' => 'jackdoe',
|
||||
'display_name' => 'jackdoe',
|
||||
'email' => 'jackdoe@example.com',
|
||||
'password' => 'password',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user