mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -20,8 +20,14 @@ class DatabaseUsersList extends Widget
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
/**
|
||||
* @return Builder<DatabaseUser>
|
||||
*/
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return DatabaseUser::query()->where('server_id', $this->server->id);
|
||||
@ -59,6 +65,9 @@ public function table(Table $table): Table
|
||||
|
||||
private function passwordAction(): Action
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
|
||||
return Action::make('password')
|
||||
->hiddenLabel()
|
||||
->icon('heroicon-o-key')
|
||||
@ -66,14 +75,14 @@ private function passwordAction(): Action
|
||||
->modalHeading('Database user\'s password')
|
||||
->modalWidth(MaxWidth::Large)
|
||||
->tooltip('Show the password')
|
||||
->authorize(fn ($record) => auth()->user()->can('view', $record))
|
||||
->authorize(fn ($record) => $user->can('view', $record))
|
||||
->form([
|
||||
TextInput::make('password')
|
||||
->label('Password')
|
||||
->default(fn (DatabaseUser $record) => $record->password)
|
||||
->disabled(),
|
||||
])
|
||||
->action(function (DatabaseUser $record, array $data) {
|
||||
->action(function (DatabaseUser $record, array $data): void {
|
||||
//
|
||||
})
|
||||
->modalSubmitAction(false)
|
||||
@ -82,6 +91,9 @@ private function passwordAction(): Action
|
||||
|
||||
private function linkAction(): Action
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
|
||||
return Action::make('link')
|
||||
->hiddenLabel()
|
||||
->icon('heroicon-o-link')
|
||||
@ -89,16 +101,16 @@ private function linkAction(): Action
|
||||
->modalWidth(MaxWidth::Large)
|
||||
->tooltip('Link user')
|
||||
->modalSubmitActionLabel('Save')
|
||||
->authorize(fn ($record) => auth()->user()->can('update', $record))
|
||||
->authorize(fn ($record) => $user->can('update', $record))
|
||||
->form([
|
||||
CheckboxList::make('databases')
|
||||
->label('Databases')
|
||||
->options($this->server->databases()->pluck('name', 'name')->toArray())
|
||||
->rules(fn (callable $get) => LinkUser::rules($this->server, $get()))
|
||||
->rules(fn (callable $get): array => LinkUser::rules($this->server, $get()))
|
||||
->default(fn (DatabaseUser $record) => $record->databases),
|
||||
])
|
||||
->action(function (DatabaseUser $record, array $data) {
|
||||
run_action($this, function () use ($record, $data) {
|
||||
->action(function (DatabaseUser $record, array $data): void {
|
||||
run_action($this, function () use ($record, $data): void {
|
||||
app(LinkUser::class)->link($record, $data);
|
||||
|
||||
Notification::make()
|
||||
@ -111,16 +123,19 @@ private function linkAction(): Action
|
||||
|
||||
private function deleteAction(): Action
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
|
||||
return Action::make('delete')
|
||||
->hiddenLabel()
|
||||
->icon('heroicon-o-trash')
|
||||
->modalHeading('Delete Database User')
|
||||
->color('danger')
|
||||
->tooltip('Delete')
|
||||
->authorize(fn ($record) => auth()->user()->can('delete', $record))
|
||||
->authorize(fn ($record) => $user->can('delete', $record))
|
||||
->requiresConfirmation()
|
||||
->action(function (DatabaseUser $record) {
|
||||
run_action($this, function () use ($record) {
|
||||
->action(function (DatabaseUser $record): void {
|
||||
run_action($this, function () use ($record): void {
|
||||
app(DeleteDatabaseUser::class)->delete($this->server, $record);
|
||||
$this->dispatch('$refresh');
|
||||
});
|
||||
|
Reference in New Issue
Block a user