Skip to content

Commit 195c82d

Browse files
Change Username field to Email field in User Nova resource with updated validation rules
1 parent 75fe2d7 commit 195c82d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/Nova/User.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Helpers\Policy;
77
use Illuminate\Validation\Rules;
88
use Laravel\Nova\Fields\Avatar;
9+
use Laravel\Nova\Fields\Email;
910
use Laravel\Nova\Fields\HasMany;
1011
use Laravel\Nova\Fields\Password;
1112
use Laravel\Nova\Fields\PasswordConfirmation;
@@ -62,9 +63,9 @@ public function fields(NovaRequest $request)
6263
return [
6364
Avatar::make('Avatar')->disableDownload()->disk('avatars')->prunable(),
6465
Panel::make('Akun', [
65-
Text::make('Username', 'email')
66+
Email::make('Email', 'email')
6667
->sortable()
67-
->rules('required', 'regex:/^[0-9A-Za-z.\-_]+$/u', 'max:254')
68+
->rules('required', 'email', 'max:254')
6869
->creationRules('unique:users,email')
6970
->updateRules('unique:users,email,{{resourceId}}')
7071
->readonly(! Policy::make()->allowedFor('admin')->get()),

0 commit comments

Comments
 (0)