mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 16:02:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -18,8 +18,14 @@ class CronJobsList extends Widget
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
/**
|
||||
* @return Builder<CronJob>
|
||||
*/
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return CronJob::query()->where('server_id', $this->server->id);
|
||||
@ -34,7 +40,7 @@ protected function getTableColumns(): array
|
||||
->searchable()
|
||||
->copyable(),
|
||||
TextColumn::make('frequency')
|
||||
->formatStateUsing(fn (CronJob $cronJob) => $cronJob->frequencyLabel())
|
||||
->formatStateUsing(fn (CronJob $cronJob): string => $cronJob->frequencyLabel())
|
||||
->searchable()
|
||||
->sortable()
|
||||
->copyable(),
|
||||
@ -52,6 +58,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())
|
||||
@ -62,10 +71,10 @@ public function table(Table $table): Table
|
||||
->tooltip('Enable')
|
||||
->icon('heroicon-o-play')
|
||||
->requiresConfirmation()
|
||||
->authorize(fn (CronJob $record) => auth()->user()->can('update', [$record, $this->server]))
|
||||
->visible(fn (CronJob $record) => $record->isDisabled())
|
||||
->action(function (CronJob $record) {
|
||||
run_action($this, function () use ($record) {
|
||||
->authorize(fn (CronJob $record) => $user->can('update', [$record, $this->server]))
|
||||
->visible(fn (CronJob $record): bool => $record->isDisabled())
|
||||
->action(function (CronJob $record): void {
|
||||
run_action($this, function () use ($record): void {
|
||||
app(EnableCronJob::class)->enable($this->server, $record);
|
||||
});
|
||||
}),
|
||||
@ -74,10 +83,10 @@ public function table(Table $table): Table
|
||||
->tooltip('Disable')
|
||||
->icon('heroicon-o-stop')
|
||||
->requiresConfirmation()
|
||||
->authorize(fn (CronJob $record) => auth()->user()->can('update', [$record, $this->server]))
|
||||
->visible(fn (CronJob $record) => $record->isEnabled())
|
||||
->action(function (CronJob $record) {
|
||||
run_action($this, function () use ($record) {
|
||||
->authorize(fn (CronJob $record) => $user->can('update', [$record, $this->server]))
|
||||
->visible(fn (CronJob $record): bool => $record->isEnabled())
|
||||
->action(function (CronJob $record): void {
|
||||
run_action($this, function () use ($record): void {
|
||||
app(DisableCronJob::class)->disable($this->server, $record);
|
||||
});
|
||||
}),
|
||||
@ -87,8 +96,8 @@ public function table(Table $table): Table
|
||||
->color('danger')
|
||||
->hiddenLabel()
|
||||
->requiresConfirmation()
|
||||
->authorize(fn (CronJob $record) => auth()->user()->can('delete', $record))
|
||||
->action(function (CronJob $record) {
|
||||
->authorize(fn (CronJob $record) => $user->can('delete', $record))
|
||||
->action(function (CronJob $record): void {
|
||||
try {
|
||||
app(DeleteCronJob::class)->delete($this->server, $record);
|
||||
} catch (\Exception $e) {
|
||||
|
Reference in New Issue
Block a user