Formato correcto de fecha y bool
This commit is contained in:
@ -21,13 +21,14 @@ class Job extends Ideal\Repository
|
|||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
return json_decode($data['configuration'], true);
|
return json_decode($data['configuration'], true);
|
||||||
}))
|
}))
|
||||||
->register('executed', new Implement\Repository\Mapper\Boolean('executed'));
|
->register('executed', new Implement\Repository\Mapper\Boolean('executed')
|
||||||
|
->setDefault(false));
|
||||||
return $this->parseData(new Model\Job(), $data, $map);
|
return $this->parseData(new Model\Job(), $data, $map);
|
||||||
}
|
}
|
||||||
public function save(Define\Model $model): Model\Job
|
public function save(Define\Model $model): Model\Job
|
||||||
{
|
{
|
||||||
$model->id = $this->saveNew(['configuration', 'executed', 'created_at'],
|
$model->id = $this->saveNew(['configuration', 'executed', 'created_at'],
|
||||||
[json_encode($model->configuration), $model->executed, (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]);
|
[json_encode($model->configuration), $model->executed ? 1 : 0, (new DateTimeImmutable())->format('Y-m-d H:i:s')]);
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
public function edit(Define\Model $model, array $new_data): Model\Job
|
public function edit(Define\Model $model, array $new_data): Model\Job
|
||||||
@ -35,8 +36,11 @@ class Job extends Ideal\Repository
|
|||||||
if (isset($new_data['configuration']) and !is_string($new_data['configuration'])) {
|
if (isset($new_data['configuration']) and !is_string($new_data['configuration'])) {
|
||||||
$new_data['configuration'] = json_encode($new_data['configuration']);
|
$new_data['configuration'] = json_encode($new_data['configuration']);
|
||||||
}
|
}
|
||||||
|
if (isset($new_data['executed'])) {
|
||||||
|
$new_data['executed'] = $new_data['executed'] ? 1 : 0;
|
||||||
|
}
|
||||||
return $this->update($model, ['configuration', 'executed', 'updated_at'],
|
return $this->update($model, ['configuration', 'executed', 'updated_at'],
|
||||||
array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
|
array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s')]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user