Skip to content

Commit

Permalink
Check for null (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored Aug 17, 2023
1 parent 516ff49 commit 693c717
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/GraphQL/Types/BeamClaimType.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function fields(): array
'code' => [
'type' => GraphQL::type('String!'),
'description' => __('enjin-platform-beam::type.beam_claim.field.code'),
'resolve' => fn ($claim) => $claim->singleUseCode,
'resolve' => fn ($claim) => $claim->code ? $claim->singleUseCode : '',
],
'identifierCode' => [
'type' => GraphQL::type('String!'),
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Laravel/BeamClaim.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function scopeWithSingleUseCode(Builder $query, string $code): Builder
public function singleUseCode(): Attribute
{
return Attribute::make(
get: fn () => encrypt(implode(':', [$this->code, $this->beam->code, $this->nonce]))
get: fn () => encrypt(implode(':', [$this->code, $this->beam?->code, $this->nonce]))
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Models/Laravel/Traits/EagerLoadSelectFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public static function loadClaims(
];
}

foreach (BeamClaimType::getRelationFields($fieldKeys) as $relation) {
foreach ([
...BeamClaimType::getRelationFields($fieldKeys),
...(isset($fields['code']) ? ['beam'] : []),
] as $relation) {
$with = array_merge(
$with,
static::getRelationQuery(
Expand Down

0 comments on commit 693c717

Please sign in to comment.