mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-09 16:52:17 +01:00
Prevent and remove zero values for billable rates
This commit is contained in:
committed by
Constantin Graf
parent
92dde6a701
commit
bd9cede081
@@ -58,12 +58,14 @@ class ImportDatabaseHelper
|
||||
*/
|
||||
private array $validate;
|
||||
|
||||
private ?Closure $beforeSave;
|
||||
|
||||
/**
|
||||
* @param class-string<TModel> $model
|
||||
* @param array<string> $identifiers
|
||||
* @param array<string, array<int, string>> $validate
|
||||
*/
|
||||
public function __construct(string $model, array $identifiers, bool $attachToExisting = false, ?Closure $queryModifier = null, ?Closure $afterCreate = null, array $validate = [])
|
||||
public function __construct(string $model, array $identifiers, bool $attachToExisting = false, ?Closure $queryModifier = null, ?Closure $afterCreate = null, array $validate = [], ?Closure $beforeSave = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->identifiers = $identifiers;
|
||||
@@ -72,6 +74,7 @@ class ImportDatabaseHelper
|
||||
$this->afterCreate = $afterCreate;
|
||||
$this->createdCount = 0;
|
||||
$this->validate = $validate;
|
||||
$this->beforeSave = $beforeSave;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,6 +102,9 @@ class ImportDatabaseHelper
|
||||
foreach ($data as $key => $value) {
|
||||
$model->{$key} = $value;
|
||||
}
|
||||
if ($this->beforeSave !== null) {
|
||||
($this->beforeSave)($model);
|
||||
}
|
||||
$model->save();
|
||||
|
||||
if ($this->afterCreate !== null) {
|
||||
|
||||
Reference in New Issue
Block a user