From e2b158815a8b51766327c2d5f49bc397fc074b2e Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 12 Apr 2024 10:54:36 +0200 Subject: [PATCH] up --- Models/BaseModel.php | 17 +++++---- Models/BaseMorphPivot.php | 15 ++++---- Models/Export.php | 48 ++++++++++++------------- Models/FailedImportRow.php | 48 ++++++++++++------------- Models/FailedJob.php | 18 ++++++---- Models/Import.php | 48 ++++++++++++------------- Models/Job.php | 28 +++++++++------ Models/JobBatch.php | 27 ++++++++------ Models/JobManager.php | 37 +++++++++++-------- Models/Result.php | 17 +++++---- Models/Schedule.php | 74 +++++++++++++++++++++----------------- Models/ScheduleHistory.php | 40 ++++++++++++--------- 12 files changed, 228 insertions(+), 189 deletions(-) diff --git a/Models/BaseModel.php b/Models/BaseModel.php index f79456aa..fc81648a 100644 --- a/Models/BaseModel.php +++ b/Models/BaseModel.php @@ -44,13 +44,16 @@ abstract class BaseModel extends Model /** @var array */ protected $fillable = ['id']; - /** @var array */ - protected $casts = [ - 'published_at' => 'datetime', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'deleted_at' => 'datetime', - ]; + /** @return array */ + protected function casts(): array + { + return [ + 'published_at' => 'datetime', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', + ]; + } /** @var string */ protected $primaryKey = 'id'; diff --git a/Models/BaseMorphPivot.php b/Models/BaseMorphPivot.php index f8b8a80b..ee098b3f 100644 --- a/Models/BaseMorphPivot.php +++ b/Models/BaseMorphPivot.php @@ -50,9 +50,12 @@ abstract class BaseMorphPivot extends MorphPivot 'note', ]; - protected $casts = [ - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'deleted_at' => 'datetime', - ]; -} \ No newline at end of file + protected function casts(): array + { + return [ + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', + ]; + } +} diff --git a/Models/Export.php b/Models/Export.php index 259fa8a0..77209f2b 100644 --- a/Models/Export.php +++ b/Models/Export.php @@ -9,20 +9,13 @@ namespace Modules\Job\Models; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Support\Carbon; - -use function Safe\json_decode; - -use Webmozart\Assert\Assert; /** - * - * * @method static \Modules\Job\Database\Factories\ExportFactory factory($count = null, $state = []) - * @method static Builder|Export newModelQuery() - * @method static Builder|Export newQuery() - * @method static Builder|Export query() + * @method static Builder|Export newModelQuery() + * @method static Builder|Export newQuery() + * @method static Builder|Export query() + * * @mixin \Eloquent */ class Export extends BaseModel @@ -39,18 +32,21 @@ class Export extends BaseModel 'user_id', ]; - protected $casts = [ - 'data' => 'json', - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'payload' => 'array', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'completed_at' => 'datetime', - // 'updated_at' => 'datetime:Y-m-d H:00', - // 'created_at' => 'datetime:Y-m-d', - // 'created_at' => 'datetime:d/m/Y H:i' - ]; -} \ No newline at end of file + protected function casts(): array + { + return [ + 'data' => 'json', + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'payload' => 'array', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'completed_at' => 'datetime', + // 'updated_at' => 'datetime:Y-m-d H:00', + // 'created_at' => 'datetime:Y-m-d', + // 'created_at' => 'datetime:d/m/Y H:i' + ]; + } +} diff --git a/Models/FailedImportRow.php b/Models/FailedImportRow.php index 974aa5ee..0a4566b6 100644 --- a/Models/FailedImportRow.php +++ b/Models/FailedImportRow.php @@ -9,20 +9,13 @@ namespace Modules\Job\Models; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Support\Carbon; - -use function Safe\json_decode; - -use Webmozart\Assert\Assert; /** - * - * * @method static \Modules\Job\Database\Factories\FailedImportRowFactory factory($count = null, $state = []) - * @method static Builder|FailedImportRow newModelQuery() - * @method static Builder|FailedImportRow newQuery() - * @method static Builder|FailedImportRow query() + * @method static Builder|FailedImportRow newModelQuery() + * @method static Builder|FailedImportRow newQuery() + * @method static Builder|FailedImportRow query() + * * @mixin \Eloquent */ class FailedImportRow extends BaseModel @@ -34,18 +27,21 @@ class FailedImportRow extends BaseModel 'validation_error', ]; - protected $casts = [ - 'data' => 'json', - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'payload' => 'array', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'completed_at' => 'datetime', - // 'updated_at' => 'datetime:Y-m-d H:00', - // 'created_at' => 'datetime:Y-m-d', - // 'created_at' => 'datetime:d/m/Y H:i' - ]; -} \ No newline at end of file + protected function casts(): array + { + return [ + 'data' => 'json', + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'payload' => 'array', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'completed_at' => 'datetime', + // 'updated_at' => 'datetime:Y-m-d H:00', + // 'created_at' => 'datetime:Y-m-d', + // 'created_at' => 'datetime:d/m/Y H:i' + ]; + } +} diff --git a/Models/FailedJob.php b/Models/FailedJob.php index b9a59cca..24ba92ba 100644 --- a/Models/FailedJob.php +++ b/Models/FailedJob.php @@ -17,6 +17,7 @@ * @method static Builder|FailedJob newModelQuery() * @method static Builder|FailedJob newQuery() * @method static Builder|FailedJob query() + * * @property int $id * @property string $uuid * @property string $connection @@ -24,6 +25,7 @@ * @property array $payload * @property string $exception * @property string $failed_at + * * @method static Builder|FailedJob whereConnection($value) * @method static Builder|FailedJob whereException($value) * @method static Builder|FailedJob whereFailedAt($value) @@ -31,6 +33,7 @@ * @method static Builder|FailedJob wherePayload($value) * @method static Builder|FailedJob whereQueue($value) * @method static Builder|FailedJob whereUuid($value) + * * @mixin \Eloquent */ class FailedJob extends BaseModel @@ -45,11 +48,14 @@ class FailedJob extends BaseModel 'failed_at', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', - 'payload' => 'array', - ]; + 'payload' => 'array', + ]; + } } diff --git a/Models/Import.php b/Models/Import.php index ddc2c25d..a82d4aae 100644 --- a/Models/Import.php +++ b/Models/Import.php @@ -9,20 +9,13 @@ namespace Modules\Job\Models; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Support\Carbon; - -use function Safe\json_decode; - -use Webmozart\Assert\Assert; /** - * - * * @method static \Modules\Job\Database\Factories\ImportFactory factory($count = null, $state = []) - * @method static Builder|Import newModelQuery() - * @method static Builder|Import newQuery() - * @method static Builder|Import query() + * @method static Builder|Import newModelQuery() + * @method static Builder|Import newQuery() + * @method static Builder|Import query() + * * @mixin \Eloquent */ class Import extends BaseModel @@ -39,18 +32,21 @@ class Import extends BaseModel 'user_id', ]; - protected $casts = [ - 'data' => 'json', - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'payload' => 'array', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'completed_at' => 'datetime', - // 'updated_at' => 'datetime:Y-m-d H:00', - // 'created_at' => 'datetime:Y-m-d', - // 'created_at' => 'datetime:d/m/Y H:i' - ]; -} \ No newline at end of file + protected function casts(): array + { + return [ + 'data' => 'json', + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'payload' => 'array', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'completed_at' => 'datetime', + // 'updated_at' => 'datetime:Y-m-d H:00', + // 'created_at' => 'datetime:Y-m-d', + // 'created_at' => 'datetime:d/m/Y H:i' + ]; + } +} diff --git a/Models/Job.php b/Models/Job.php index 7791c205..4115ef50 100644 --- a/Models/Job.php +++ b/Models/Job.php @@ -29,6 +29,7 @@ * @property string|null $created_by * @property string|null $updated_by * @property Carbon|null $updated_at + * * @method static \Modules\Job\Database\Factories\JobFactory factory($count = null, $state = []) * @method static Builder|Job newModelQuery() * @method static Builder|Job newQuery() @@ -43,8 +44,10 @@ * @method static Builder|Job whereReservedAt($value) * @method static Builder|Job whereUpdatedAt($value) * @method static Builder|Job whereUpdatedBy($value) + * * @property mixed $display_name * @property mixed $status + * * @mixin \Eloquent */ class Job extends BaseModel @@ -59,18 +62,21 @@ class Job extends BaseModel 'created_at', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', - 'payload' => 'array', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - // 'updated_at' => 'datetime:Y-m-d H:00', - // 'created_at' => 'datetime:Y-m-d', - // 'created_at' => 'datetime:d/m/Y H:i' - ]; + 'payload' => 'array', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + // 'updated_at' => 'datetime:Y-m-d H:00', + // 'created_at' => 'datetime:Y-m-d', + // 'created_at' => 'datetime:d/m/Y H:i' + ]; + } public function getTable(): string { diff --git a/Models/JobBatch.php b/Models/JobBatch.php index 965bd470..6584fd9e 100644 --- a/Models/JobBatch.php +++ b/Models/JobBatch.php @@ -27,6 +27,7 @@ * @property Carbon|null $cancelled_at * @property Carbon $created_at * @property Carbon|null $finished_at + * * @method static \Modules\Job\Database\Factories\JobBatchFactory factory($count = null, $state = []) * @method static Builder|JobBatch newModelQuery() * @method static Builder|JobBatch newQuery() @@ -41,6 +42,7 @@ * @method static Builder|JobBatch whereOptions($value) * @method static Builder|JobBatch wherePendingJobs($value) * @method static Builder|JobBatch whereTotalJobs($value) + * * @mixin \Eloquent */ class JobBatch extends BaseModel @@ -81,17 +83,20 @@ class JobBatch extends BaseModel * * @var array */ - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'options' => 'collection', - 'failed_jobs' => 'integer', - 'created_at' => 'datetime', - 'cancelled_at' => 'datetime', - 'finished_at' => 'datetime', - ]; + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'options' => 'collection', + 'failed_jobs' => 'integer', + 'created_at' => 'datetime', + 'cancelled_at' => 'datetime', + 'finished_at' => 'datetime', + ]; + } /** * Get the total number of jobs that have been processed by the batch thus far. diff --git a/Models/JobManager.php b/Models/JobManager.php index 2702428d..8341e19b 100644 --- a/Models/JobManager.php +++ b/Models/JobManager.php @@ -22,18 +22,21 @@ * @property Carbon|null $cancelled_at * @property Carbon $created_at * @property Carbon|null $finished_at + * * @method static \Modules\Job\Database\Factories\JobManagerFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|JobManager newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|JobManager newQuery() * @method static \Illuminate\Database\Eloquent\Builder|JobManager query() - * @property mixed $status - * @property string $job_id - * @property string|null $queue + * + * @property mixed $status + * @property string $job_id + * @property string|null $queue * @property \Illuminate\Support\Carbon|null $started_at - * @property int $attempt - * @property int|null $progress - * @property string|null $exception_message + * @property int $attempt + * @property int|null $progress + * @property string|null $exception_message * @property \Illuminate\Support\Carbon|null $updated_at + * * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereAttempt($value) * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereExceptionMessage($value) @@ -46,6 +49,7 @@ * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereQueue($value) * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereStartedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|JobManager whereUpdatedAt($value) + * * @mixin \Eloquent */ class JobManager extends BaseModel @@ -66,15 +70,18 @@ class JobManager extends BaseModel 'exception_message', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'failed' => 'bool', - 'started_at' => 'datetime', - 'finished_at' => 'datetime', - ]; + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'failed' => 'bool', + 'started_at' => 'datetime', + 'finished_at' => 'datetime', + ]; + } public function status(): Attribute { diff --git a/Models/Result.php b/Models/Result.php index 55bef450..8138d553 100644 --- a/Models/Result.php +++ b/Models/Result.php @@ -23,6 +23,7 @@ * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property \Modules\Job\Models\Task|null $task + * * @method static \Illuminate\Database\Eloquent\Builder|Result newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Result newQuery() * @method static \Illuminate\Database\Eloquent\Builder|Result query() @@ -35,6 +36,7 @@ * @method static \Illuminate\Database\Eloquent\Builder|Result whereTaskId($value) * @method static \Illuminate\Database\Eloquent\Builder|Result whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Result whereUpdatedBy($value) + * * @mixin \Eloquent */ class Result extends BaseModel @@ -48,13 +50,16 @@ class Result extends BaseModel 'result', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', - 'ran_at' => 'datetime', - ]; + 'ran_at' => 'datetime', + ]; + } public function task(): BelongsTo { diff --git a/Models/Schedule.php b/Models/Schedule.php index 7500496b..6d5e70df 100644 --- a/Models/Schedule.php +++ b/Models/Schedule.php @@ -18,6 +18,7 @@ * @property array $options * @property \Illuminate\Database\Eloquent\Collection $histories * @property int|null $histories_count + * * @method static Builder|Schedule active() * @method static \Modules\Job\Database\Factories\ScheduleFactory factory($count = null, $state = []) * @method static Builder|Schedule inactive() @@ -27,31 +28,33 @@ * @method static Builder|Schedule query() * @method static Builder|Schedule withTrashed() * @method static Builder|Schedule withoutTrashed() - * @property int $id - * @property string $command - * @property string|null $command_custom - * @property array|null $params - * @property string $expression - * @property array|null $environments - * @property array|null $options_with_value - * @property string|null $log_filename - * @property int $even_in_maintenance_mode - * @property int $without_overlapping - * @property int $on_one_server - * @property string|null $webhook_before - * @property string|null $webhook_after - * @property string|null $email_output - * @property int $sendmail_error - * @property int $log_success - * @property int $log_error - * @property int $run_in_background - * @property int $sendmail_success + * + * @property int $id + * @property string $command + * @property string|null $command_custom + * @property array|null $params + * @property string $expression + * @property array|null $environments + * @property array|null $options_with_value + * @property string|null $log_filename + * @property int $even_in_maintenance_mode + * @property int $without_overlapping + * @property int $on_one_server + * @property string|null $webhook_before + * @property string|null $webhook_after + * @property string|null $email_output + * @property int $sendmail_error + * @property int $log_success + * @property int $log_error + * @property int $run_in_background + * @property int $sendmail_success * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $deleted_at - * @property string|null $updated_by - * @property string|null $created_by - * @property string|null $deleted_by + * @property string|null $updated_by + * @property string|null $created_by + * @property string|null $deleted_by + * * @method static Builder|Schedule whereCommand($value) * @method static Builder|Schedule whereCommandCustom($value) * @method static Builder|Schedule whereCreatedAt($value) @@ -79,6 +82,7 @@ * @method static Builder|Schedule whereWebhookAfter($value) * @method static Builder|Schedule whereWebhookBefore($value) * @method static Builder|Schedule whereWithoutOverlapping($value) + * * @mixin \Eloquent */ class Schedule extends BaseModel @@ -120,17 +124,21 @@ class Schedule extends BaseModel 'options' => '{}', 'options_with_value' => '{}', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - - 'params' => 'array', - 'options' => 'array', - 'options_with_value' => 'array', - 'environments' => 'array', - 'status' => Status::class, - ]; + + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'params' => 'array', + 'options' => 'array', + 'options_with_value' => 'array', + 'environments' => 'array', + 'status' => Status::class, + ]; + } /* * Creates a new instance of the model. * diff --git a/Models/ScheduleHistory.php b/Models/ScheduleHistory.php index 30b48b7c..24fe5ac6 100644 --- a/Models/ScheduleHistory.php +++ b/Models/ScheduleHistory.php @@ -14,21 +14,24 @@ * Modules\Job\Models\ScheduleHistory. * * @property \Modules\Job\Models\Schedule|null $command + * * @method static \Modules\Job\Database\Factories\ScheduleHistoryFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory newQuery() * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory query() - * @property int $id - * @property array|null $params - * @property string $output - * @property array|null $options + * + * @property int $id + * @property array|null $params + * @property string $output + * @property array|null $options * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at - * @property int|null $schedule_id - * @property string|null $updated_by - * @property string|null $created_by - * @property string|null $deleted_at - * @property string|null $deleted_by + * @property int|null $schedule_id + * @property string|null $updated_by + * @property string|null $created_by + * @property string|null $deleted_at + * @property string|null $deleted_by + * * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereCommand($value) * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereCreatedBy($value) @@ -41,6 +44,7 @@ * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereScheduleId($value) * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ScheduleHistory whereUpdatedBy($value) + * * @mixin \Eloquent */ class ScheduleHistory extends BaseModel @@ -58,14 +62,18 @@ class ScheduleHistory extends BaseModel 'output', 'options', ]; - protected $casts = [ - 'updated_by' => 'string', - 'created_by' => 'string', - 'deleted_by' => 'string', - 'params' => 'array', - 'options' => 'array', - ]; + protected function casts(): array + { + return [ + 'updated_by' => 'string', + 'created_by' => 'string', + 'deleted_by' => 'string', + + 'params' => 'array', + 'options' => 'array', + ]; + } /* * Creates a new instance of the model. *