Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Jul 30, 2024
1 parent d38c19b commit a47dd5d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Services/BeamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ public function findByCode(string $code): ?Model
*/
public function scanByCode(string $code, ?string $wallet = null): ?Model
{
$isSingleUse = static::isSingleUse($code);
$beamCode = static::getSingleUseCodeData($code)?->beamCode;
$beam = Beam::whereCode($beamCode ?? $code)->firstOrFail();
($beam->is_pack ? new BeamPack() : new BeamClaim())
->withSingleUseCode($code)
->firstOrFail();

$beam = $isSingleUse
? BeamClaim::withSingleUseCode($code)
->with('beam')
->first()
->beam
: $this->findByCode($code);
if ($wallet) {
// Pushing this to the queue for performance
CreateClaim::dispatch($claim = [
Expand All @@ -193,7 +191,7 @@ public function scanByCode(string $code, ?string $wallet = null): ?Model
$beam->setRelation('scans', collect(json_decode(json_encode([$claim]))));
}

if ($isSingleUse) {
if ($beamCode) {
$beam['code'] = $code;
}

Expand Down

0 comments on commit a47dd5d

Please sign in to comment.