-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab1b81
commit ccbbdef
Showing
7 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
web/Modules/Customer/App/Filament/Resources/CronJobResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace Modules\Customer\App\Filament\Resources; | ||
|
||
use App\Models\CronJob; | ||
use App\Models\HostingSubscription; | ||
use Modules\Customer\App\Filament\Resources\CronJobResource\Pages; | ||
use Modules\Customer\App\Filament\Resources\CronJobResource\RelationManagers; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
|
||
class CronJobResource extends Resource | ||
{ | ||
protected static ?string $model = CronJob::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-clock'; | ||
|
||
protected static ?int $navigationSort = 5; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
|
||
Forms\Components\Select::make('hosting_subscription_id') | ||
->label('Hosting Subscription') | ||
->options( | ||
\App\Models\HostingSubscription::all()->pluck('domain', 'id') | ||
) | ||
->live() | ||
->disabled(function ($record) { | ||
return $record; | ||
}) | ||
->columnSpanFull() | ||
->required(), | ||
|
||
Forms\Components\TextInput::make('schedule') | ||
->autofocus() | ||
->required() | ||
->columnSpanFull() | ||
->helperText('The schedule to run the command. Example: * * * * *') | ||
->label('Schedule'), | ||
Forms\Components\TextInput::make('command') | ||
->required() | ||
->columnSpanFull() | ||
->helperText('The command to run. Example: ls -la') | ||
->label('Command'), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('schedule') | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('command') | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('user') | ||
->searchable() | ||
->sortable(), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListCronJobs::route('/'), | ||
'create' => Pages\CreateCronJob::route('/create'), | ||
'edit' => Pages\EditCronJob::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
web/Modules/Customer/App/Filament/Resources/CronJobResource/Pages/CreateCronJob.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Modules\Customer\App\Filament\Resources\CronJobResource\Pages; | ||
|
||
use Modules\Customer\App\Filament\Resources\CronJobResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateCronJob extends CreateRecord | ||
{ | ||
protected static string $resource = CronJobResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
web/Modules/Customer/App/Filament/Resources/CronJobResource/Pages/EditCronJob.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Modules\Customer\App\Filament\Resources\CronJobResource\Pages; | ||
|
||
use Modules\Customer\App\Filament\Resources\CronJobResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditCronJob extends EditRecord | ||
{ | ||
protected static string $resource = CronJobResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
web/Modules/Customer/App/Filament/Resources/CronJobResource/Pages/ListCronJobs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Modules\Customer\App\Filament\Resources\CronJobResource\Pages; | ||
|
||
use Modules\Customer\App\Filament\Resources\CronJobResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListCronJobs extends ListRecords | ||
{ | ||
protected static string $resource = CronJobResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ protected static function booted(): void | |
}); | ||
} | ||
|
||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters