Skip to content

Commit

Permalink
Avoid initialisation primary key model property to fix missing ID pre…
Browse files Browse the repository at this point in the history
…loading by CycleORM on relation query build
  • Loading branch information
vokomarov committed Oct 19, 2021
1 parent 5b1ef2e commit 1d29062
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/src/Controller/Profile/ProfileStatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function walletsLatest(
$wallets = $walletRepository->findByUserPKLatestWithLimit($this->user->id);

foreach ($wallets as $wallet) {
$wallet->latestCharges = new ArrayCollection($chargeRepository->findByWalletIDLatest($wallet->id));
$wallet->latestCharges = new ArrayCollection($chargeRepository->findByWalletIDLatest((int) $wallet->id));
}

return $view->json($wallets);
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/Wallets/Charges/ChargesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function list(int $walletId): ResponseInterface

$charges = $this->charges
->paginate($this->paginators->createPaginator())
->findByWalletId($wallet->id);
->findByWalletId((int) $wallet->id);

if (count($charges) === 0) {
return $this->response->json(['data' => []]);
Expand Down Expand Up @@ -68,7 +68,7 @@ public function create(int $walletId, CreateRequest $request): ResponseInterface
$charge->title = $request->getTitle();
$charge->description = $request->getDescription();
$charge->wallet = $wallet;
$charge->walletId = $wallet->id;
$charge->walletId = (int) $wallet->id;
$charge->user = $this->user;
$charge->userId = $this->user->id;

Expand Down
4 changes: 2 additions & 2 deletions app/src/Database/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Wallet
{
/**
* @Cycle\Column(type = "primary")
* @var int
* @var int|null
*/
public $id = 0;
public $id;

/**
* @Cycle\Column(type = "string")
Expand Down
2 changes: 1 addition & 1 deletion app/src/Service/Statistics/ProfileStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
public function getChargeFlow(User $user, Currency $currency): array
{
$walletIDs = array_map(function (Wallet $wallet) {
return $wallet->id;
return (int) $wallet->id;
}, $this->walletRepository->findAllByUserPKByCurrencyCode($user->id, $currency->code));

$data = [
Expand Down
2 changes: 1 addition & 1 deletion app/src/Service/UriService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(AppConfig $config)
*/
public function wallet(Wallet $wallet): string
{
return $this->config->getWebAppUrl() . $this->config->getWalletLink($wallet->id);
return $this->config->getWebAppUrl() . $this->config->getWalletLink((int) $wallet->id);
}

/**
Expand Down

0 comments on commit 1d29062

Please sign in to comment.