Skip to content

Commit

Permalink
Merge pull request OpenDominion#558 from WaveHack/bugfix/op-center-br…
Browse files Browse the repository at this point in the history
…eaks-on-clairvoyance

Made InfoOp nullable, also added null check in view.
  • Loading branch information
WaveHack committed Jun 16, 2019
2 parents 5b26dda + 5669320 commit c01775c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/resources/views/pages/dominion/op-center/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@php
$lastInfoOp = $infoOpService->getLastInfoOp($selectedDominion->realm, $dominion);
@endphp
@if ($lastInfoOp->isInvalid())
@if ($lastInfoOp == null || $lastInfoOp->isInvalid())
@continue
@endif
<tr>
Expand Down Expand Up @@ -117,7 +117,7 @@
@php
$lastInfoOp = $infoOpService->getLastClairvoyance($selectedDominion->realm, $realm);
@endphp
@if ($lastInfoOp->isInvalid())
@if ($lastInfoOp == null || $lastInfoOp->isInvalid())
@continue
@endif
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Dominion/InfoOpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function getNetworthString(Realm $sourceRealm, Dominion $targetDominion):
return $return;
}

public function getLastInfoOp(Realm $sourceRealm, Dominion $targetDominion): InfoOp
public function getLastInfoOp(Realm $sourceRealm, Dominion $targetDominion): ?InfoOp
{
return $sourceRealm->infoOps->filter(function ($infoOp) use ($targetDominion) {
return ($infoOp->target_dominion_id === $targetDominion->id && $infoOp->type != 'clairvoyance');
Expand All @@ -206,7 +206,7 @@ public function getLastInfoOpName(Realm $sourceRealm, Dominion $targetDominion):
->first()['name'];
}

public function getLastClairvoyance(Realm $sourceRealm, Realm $targetRealm): InfoOp
public function getLastClairvoyance(Realm $sourceRealm, Realm $targetRealm): ?InfoOp
{
return $sourceRealm->infoOps->filter(function ($infoOp) use ($targetRealm) {
return ($infoOp->target_realm_id === $targetRealm->id && $infoOp->type == 'clairvoyance');
Expand Down

0 comments on commit c01775c

Please sign in to comment.