-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): fix data that should not be stored being stored (#226)
- Loading branch information
1 parent
e58b181
commit 77e8c09
Showing
79 changed files
with
469 additions
and
574 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\App\Order\Model; | ||
|
||
use MyParcelNL\Pdk\Base\Model\Model; | ||
use MyParcelNL\Pdk\Base\Support\Utils; | ||
use MyParcelNL\Pdk\Facade\Pdk; | ||
use MyParcelNL\Pdk\Types\Service\TriStateService; | ||
|
||
/** | ||
* @property null|int $height | ||
* @property null|int $length | ||
* @property null|int $width | ||
* @property int $initialWeight | ||
* @property int $manualWeight | ||
* @property int $totalWeight | ||
*/ | ||
class PdkPhysicalProperties extends Model | ||
{ | ||
protected $attributes = [ | ||
'height' => null, | ||
'length' => null, | ||
'width' => null, | ||
|
||
/** | ||
* Base weight. | ||
*/ | ||
'initialWeight' => 0, | ||
|
||
/** | ||
* Optional manual override of the initial weight. | ||
*/ | ||
'manualWeight' => TriStateService::INHERIT, | ||
|
||
/** | ||
* Calculated automatically based on the initial weight and manual weight. | ||
*/ | ||
'totalWeight' => 0, | ||
]; | ||
|
||
protected $casts = [ | ||
'height' => 'int', | ||
'length' => 'int', | ||
'width' => 'int', | ||
'initialWeight' => 'int', | ||
'manualWeight' => 'int', | ||
'totalWeight' => 'int', | ||
]; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toStorableArray(): array | ||
{ | ||
return Utils::filterNull([ | ||
'manualWeight' => TriStateService::INHERIT === $this->manualWeight ? null : $this->manualWeight, | ||
]); | ||
} | ||
|
||
/** | ||
* @return int | ||
* @noinspection PhpUnused | ||
*/ | ||
protected function getTotalWeightAttribute(): int | ||
{ | ||
/** @var TriStateService $triStateService */ | ||
$triStateService = Pdk::get(TriStateService::class); | ||
|
||
return $triStateService->resolve($this->manualWeight, $this->initialWeight); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.