feat: Auto-verify new user emails upon creation and remove recordTitleAttribute and autocomplete(false) from the user resource.

This commit is contained in:
Yoga Pangestu 2026-01-27 15:28:14 +07:00
parent 974d8ac92b
commit f1d1058868
2 changed files with 12 additions and 7 deletions

View File

@ -9,10 +9,10 @@
class ManageUsers extends ManageRecords class ManageUsers extends ManageRecords
{ {
protected static ?string $title = 'Pengguna';
protected static string $resource = UserResource::class; protected static string $resource = UserResource::class;
protected static ?string $title = 'Pengguna';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -25,7 +25,14 @@ protected function getHeaderActions(): array
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])
->modalWidth(Width::Large), ->modalWidth(Width::Large)
->after(function (CreateAction $action): void {
$user = $action->getRecord();
$user->update([
'email_verified_at' => now(),
]);
}),
]; ];
} }
} }

View File

@ -43,7 +43,7 @@ class UserResource extends Resource
protected static ?int $navigationSort = 8; protected static ?int $navigationSort = 8;
protected static ?string $recordTitleAttribute = 'name'; // protected static ?string $recordTitleAttribute = 'name';
protected static ?string $slug = 'master/users'; protected static ?string $slug = 'master/users';
@ -86,8 +86,7 @@ public static function form(Schema $schema): Schema
}) })
->multiple() ->multiple()
->preload() ->preload()
->searchable() ->searchable(),
->autocomplete(false),
Hidden::make('password') Hidden::make('password')
->default(fn (?User $record): ?string => $record ? null : config('auth.password_default')), ->default(fn (?User $record): ?string => $record ? null : config('auth.password_default')),
@ -98,7 +97,6 @@ public static function form(Schema $schema): Schema
public static function table(Table $table): Table public static function table(Table $table): Table
{ {
return $table return $table
->recordTitleAttribute('name')
->columns([ ->columns([
TextColumn::make('name') TextColumn::make('name')
->label('Nama') ->label('Nama')