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