-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,30 +7,12 @@ | |
use KejawenLab\Application\SemartHris\Component\Address\Model\Addressable; | ||
use KejawenLab\Application\SemartHris\Component\Address\Model\AddressInterface; | ||
use KejawenLab\Application\SemartHris\Util\StringUtil; | ||
use KejawenLab\Application\SemartHris\Util\UuidUtil; | ||
|
||
/** | ||
* @author Muhamad Surya Iksanudin <[email protected]> | ||
*/ | ||
trait AddressRepositoryTrait | ||
{ | ||
/** | ||
* @param AddressInterface $address | ||
*/ | ||
public function unsetDefaultExcept(AddressInterface $address): void | ||
{ | ||
/** @var QueryBuilder $queryBuilder */ | ||
$queryBuilder = $this->entityManager->createQueryBuilder(); | ||
$queryBuilder->from($this->getAddressClass(), 'o'); | ||
$queryBuilder->update(); | ||
$queryBuilder->set('o.defaultAddress', $queryBuilder->expr()->literal(false)); | ||
if ($address->getId() && UuidUtil::isValid($address->getId())) { | ||
$queryBuilder->andWhere($queryBuilder->expr()->neq('o.id', $queryBuilder->expr()->literal($address->getId()))); | ||
} | ||
|
||
$queryBuilder->getQuery()->execute(); | ||
} | ||
|
||
public function setRandomDefault(): AddressInterface | ||
{ | ||
/** @var AddressInterface $other */ | ||
|
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