diff --git a/resources/lang/ru/user.php b/resources/lang/ru/user.php new file mode 100644 index 0000000..fc22e3f --- /dev/null +++ b/resources/lang/ru/user.php @@ -0,0 +1,24 @@ + [ + "id" => "ID", + "single" => "Пользователь", + "email_verified_at" => "Email подтвержден", + "created_at" => "Создан", + "updated_at" => "Изменен", + "verified" => "Верифицирован", + "unverified" => "Не верифицирован", + "name" => "Имя", + "email" => "Email", + "password" => "Пароль", + "roles" => "Роли", + "label" => "Пользователи", + "title" => [ + "create" => "Создать", + "edit" => "Редактировать", + "list" => "Пользователи", + "home" => "Пользователи" + ], + ] +]; diff --git a/src/Resources/UserResource.php b/src/Resources/UserResource.php index a8b441d..590a4bc 100644 --- a/src/Resources/UserResource.php +++ b/src/Resources/UserResource.php @@ -89,7 +89,8 @@ public static function form(Form $form): Form public static function table(Table $table): Table { - return $table + !config('filament-user.impersonate') ?: $table->actions([Impersonate::make('impersonate')]); + $table ->columns([ TextColumn::make('id') ->sortable() @@ -125,13 +126,13 @@ public static function table(Table $table): Table ->query(fn(Builder $query): Builder => $query->whereNull('email_verified_at')), ]) ->actions([ - Impersonate::make('impersonate'), ActionGroup::make([ ViewAction::make(), EditAction::make(), DeleteAction::make() ]), ]); + return $table; } public static function getPages(): array diff --git a/src/Resources/UserResource/Pages/EditUser.php b/src/Resources/UserResource/Pages/EditUser.php index 39810ae..f6c8795 100644 --- a/src/Resources/UserResource/Pages/EditUser.php +++ b/src/Resources/UserResource/Pages/EditUser.php @@ -5,6 +5,8 @@ use App\Models\User; use io3x1\FilamentUser\Resources\UserResource; use Filament\Resources\Pages\EditRecord; +use Filament\Actions\DeleteAction; +use STS\FilamentImpersonate\Pages\Actions\Impersonate; class EditUser extends EditRecord { @@ -25,4 +27,12 @@ public function getTitle(): string { return trans('filament-user::user.resource.title.edit'); } + + protected function getActions(): array + { + !config('filament-user.impersonate') ?: $ret[] = Impersonate::make()->record($this->getRecord()); + $ret[] = DeleteAction::make(); + + return $ret; + } } diff --git a/src/Resources/UserResource/Pages/ListUsers.php b/src/Resources/UserResource/Pages/ListUsers.php index 6a718e2..e14d7b1 100644 --- a/src/Resources/UserResource/Pages/ListUsers.php +++ b/src/Resources/UserResource/Pages/ListUsers.php @@ -4,6 +4,7 @@ use io3x1\FilamentUser\Resources\UserResource; use Filament\Resources\Pages\ListRecords; +use Filament\Actions\CreateAction; class ListUsers extends ListRecords { @@ -13,4 +14,11 @@ public function getTitle(): string { return trans('filament-user::user.resource.title.list'); } + + protected function getActions(): array + { + return [ + CreateAction::make(), + ]; + } } diff --git a/stubs/EditUser.stub b/stubs/EditUser.stub index f9de3ad..e565d42 100644 --- a/stubs/EditUser.stub +++ b/stubs/EditUser.stub @@ -5,6 +5,8 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Models\User; use App\Filament\Resources\UserResource; use Filament\Resources\Pages\EditRecord; +use Filament\Actions\DeleteAction; +use STS\FilamentImpersonate\Pages\Actions\Impersonate; class EditUser extends EditRecord { @@ -25,4 +27,12 @@ class EditUser extends EditRecord { return trans('filament-user::user.resource.title.edit'); } + + protected function getActions(): array + { + !config('filament-user.impersonate') ?: $ret[] = Impersonate::make()->record($this->getRecord()); + $ret[] = DeleteAction::make(); + + return $ret; + } } diff --git a/stubs/ListUsers.stub b/stubs/ListUsers.stub index dd654ca..35c86c4 100644 --- a/stubs/ListUsers.stub +++ b/stubs/ListUsers.stub @@ -4,6 +4,7 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; use Filament\Resources\Pages\ListRecords; +use Filament\Actions\CreateAction; class ListUsers extends ListRecords { @@ -13,4 +14,11 @@ class ListUsers extends ListRecords { return trans('filament-user::user.resource.title.list'); } + + protected function getActions(): array + { + return [ + CreateAction::make(), + ]; + } } diff --git a/stubs/UserResource.stub b/stubs/UserResource.stub index a7ca00c..be5cecf 100644 --- a/stubs/UserResource.stub +++ b/stubs/UserResource.stub @@ -88,6 +88,7 @@ class UserResource extends Resource public static function table(Table $table): Table { + !config('filament-user.impersonate') ?: $table->actions([Impersonate::make('impersonate')]); $table ->columns([ TextColumn::make('id') @@ -130,13 +131,6 @@ class UserResource extends Resource DeleteAction::make() ]), ]); - - if(config('filament-user.impersonate')){ - $table->prependActions([ - Impersonate::make('impersonate'), - ]); - } - return $table; }