新增 TextAd 角色 動作異常 20250708
This commit is contained in:
parent
9f0b6741c2
commit
e3f9e54a4f
@ -37,16 +37,18 @@ class UserForm extends Component
|
|||||||
'birthday' => '',
|
'birthday' => '',
|
||||||
'gender' => 'unset',
|
'gender' => 'unset',
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
|
'password' => '', // 新增
|
||||||
|
'password_confirmation' => '', // 新增
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'fields.name' => 'required|string|max:255',
|
'fields.name' => 'required|string|max:255',
|
||||||
'fields.email' => 'required|string|email|max:255',
|
'fields.email' => 'required|string|email|max:255',
|
||||||
'fields.phone' => 'nullable|regex:/^09\d{8}$/',
|
'fields.phone' => 'required|regex:/^09\d{8}$/',
|
||||||
'fields.birthday' =>'nullable|date',
|
'fields.birthday' =>'nullable|date',
|
||||||
'fields.gender' => 'required|in:male,female,other,unset',
|
'fields.gender' => 'required',
|
||||||
'fields.status' => 'required|integer|in:0,1,2',
|
'fields.status' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@ -86,7 +88,16 @@ class UserForm extends Component
|
|||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
//$this->validate();
|
$rules = $this->rules;
|
||||||
|
// 加入 email / phone 唯一性驗證,排除自己(編輯時)
|
||||||
|
$rules['fields.email'] .= '|unique:users,email' . ($this->userId ? ",{$this->userId}" : '');
|
||||||
|
$rules['fields.phone'] .= '|unique:users,phone' . ($this->userId ? ",{$this->userId}" : '');
|
||||||
|
|
||||||
|
// 新增時才驗證密碼
|
||||||
|
if (!$this->userId) {
|
||||||
|
$rules['fields.password'] = ['required', 'string', 'min:8', 'confirmed'];
|
||||||
|
}
|
||||||
|
$validated = $this->validate($rules);
|
||||||
|
|
||||||
if ($this->userId) {
|
if ($this->userId) {
|
||||||
if ($this->canEdit) {
|
if ($this->canEdit) {
|
||||||
|
@ -29,6 +29,20 @@
|
|||||||
option-value="value"
|
option-value="value"
|
||||||
:options="$rolesOptions->map(fn($p) => ['value' => $p->id, 'label' => $p->name])->toArray()"
|
:options="$rolesOptions->map(fn($p) => ['value' => $p->id, 'label' => $p->name])->toArray()"
|
||||||
/>
|
/>
|
||||||
|
@if (!$userId)
|
||||||
|
<x-wireui:input
|
||||||
|
label="{{ __('users.password') }}"
|
||||||
|
wire:model.defer="fields.password"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<x-wireui:input
|
||||||
|
label="{{ __('users.password_confirmation') }}"
|
||||||
|
wire:model.defer="fields.password_confirmation"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-slot name="footer">
|
<x-slot name="footer">
|
||||||
|
@ -62,7 +62,12 @@ new #[Layout('layouts.guest')] class extends Component
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center justify-end mt-4">
|
<div class="flex items-center justify-end mt-4 space-x-4">
|
||||||
|
@if (Route::has('register'))
|
||||||
|
<a class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" href="{{ route('register') }}" wire:navigate>
|
||||||
|
註冊
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
@if (Route::has('password.request'))
|
@if (Route::has('password.request'))
|
||||||
<a class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" href="{{ route('password.request') }}" wire:navigate>
|
<a class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" href="{{ route('password.request') }}" wire:navigate>
|
||||||
{{ __('Forgot your password?') }}
|
{{ __('Forgot your password?') }}
|
||||||
|
@ -12,6 +12,7 @@ new #[Layout('layouts.guest')] class extends Component
|
|||||||
{
|
{
|
||||||
public string $name = '';
|
public string $name = '';
|
||||||
public string $email = '';
|
public string $email = '';
|
||||||
|
public string $phone = '';
|
||||||
public string $password = '';
|
public string $password = '';
|
||||||
public string $password_confirmation = '';
|
public string $password_confirmation = '';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user