mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 08:52:35 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -17,6 +17,9 @@ class Index extends Page
|
||||
|
||||
protected static ?string $title = 'Cron Jobs';
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
public function mount(): void
|
||||
@ -64,11 +67,11 @@ protected function getHeaderActions(): array
|
||||
TextInput::make('custom')
|
||||
->label('Custom Frequency (Cron)')
|
||||
->rules(fn (callable $get) => CreateCronJob::rules($get(), $this->server)['custom'])
|
||||
->visible(fn (callable $get) => $get('frequency') === 'custom')
|
||||
->visible(fn (callable $get): bool => $get('frequency') === 'custom')
|
||||
->placeholder('0 * * * *'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
run_action($this, function () use ($data) {
|
||||
->action(function (array $data): void {
|
||||
run_action($this, function () use ($data): void {
|
||||
app(CreateCronJob::class)->create($this->server, $data);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
|
@ -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