mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 23:42:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -24,7 +24,10 @@ class Index extends Page
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('viewAny', SshKey::class) ?? false;
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('viewAny', SshKey::class);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
@ -36,6 +39,9 @@ public function getWidgets(): array
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return [
|
||||
CreateAction::make('add')
|
||||
->label('Add Key')
|
||||
@ -53,8 +59,8 @@ protected function getHeaderActions(): array
|
||||
])
|
||||
->authorize('create', SshKey::class)
|
||||
->modalWidth(MaxWidth::Large)
|
||||
->using(function (array $data) {
|
||||
app(CreateSshKey::class)->create(auth()->user(), $data);
|
||||
->using(function (array $data) use ($user): void {
|
||||
app(CreateSshKey::class)->create($user, $data);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
}),
|
||||
|
@ -11,8 +11,14 @@
|
||||
|
||||
class SshKeysList extends TableWidget
|
||||
{
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
/**
|
||||
* @return Builder<SshKey>
|
||||
*/
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return SshKey::query()->where('user_id', auth()->id());
|
||||
@ -35,6 +41,9 @@ protected function getTableColumns(): array
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $table
|
||||
->heading(null)
|
||||
->query($this->getTableQuery())
|
||||
@ -42,9 +51,9 @@ public function table(Table $table): Table
|
||||
->actions([
|
||||
DeleteAction::make('delete')
|
||||
->requiresConfirmation()
|
||||
->authorize(fn (SshKey $record) => auth()->user()->can('delete', $record))
|
||||
->action(function (SshKey $record) {
|
||||
run_action($this, function () use ($record) {
|
||||
->authorize(fn (SshKey $record) => $user->can('delete', $record))
|
||||
->action(function (SshKey $record): void {
|
||||
run_action($this, function () use ($record): void {
|
||||
$record->delete();
|
||||
$this->dispatch('$refresh');
|
||||
});
|
||||
|
Reference in New Issue
Block a user