-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLA-1778] Add singleUseCodes filter to GetClaims query. (#71)
- Loading branch information
1 parent
b03d2e0
commit 91347ae
Showing
7 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Enjin\Platform\Beam\Models\Laravel\Traits; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\Builder; | ||
use Illuminate\Support\Arr; | ||
|
||
trait HasSingleUseCodeScope | ||
{ | ||
/** | ||
* Local scope for beam code. | ||
*/ | ||
public function scopeHasSingleUseCode(Builder $query, string|array|null $code): Builder | ||
{ | ||
try { | ||
if (is_array($code)) { | ||
$singleUseCode = array_map(function ($item) { | ||
return explode(':', decrypt($item))[0]; | ||
}, $code); | ||
} else { | ||
$singleUseCode = explode(':', decrypt($code))[0]; | ||
} | ||
|
||
return $query->whereIn('code', Arr::wrap($singleUseCode)); | ||
} catch (\Throwable $exception) { | ||
return $query; | ||
} | ||
} | ||
} |
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