This commit is contained in:
Bozhidar 2024-04-26 19:22:55 +03:00
parent ccbbdefda1
commit 3fc7ea370a
2 changed files with 11 additions and 0 deletions

View file

@ -66,6 +66,9 @@ class CronJobResource extends Resource
Tables\Columns\TextColumn::make('user')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('hostingSubscription.domain')
->searchable()
->sortable(),
])
->filters([
//

View file

@ -12,6 +12,7 @@ class CronJob extends Model
'schedule',
'command',
'user',
'hosting_subscription_id'
];
protected static function booted(): void
@ -35,6 +36,12 @@ class CronJob extends Model
parent::boot();
static::creating(function ($model) {
if ($model->hosting_subscription_id) {
$hostingSubscription = HostingSubscription::where('id', $model->hosting_subscription_id)->first();
if ($hostingSubscription) {
$model->user = $hostingSubscription->system_username;
}
}
$allCronJobs = [];
$oldCronJobs = self::where('user', $model->user)->get();
foreach ($oldCronJobs as $oldCronJob) {
@ -101,4 +108,5 @@ class CronJob extends Model
return false;
}
}