Skip to content

Commit

Permalink
[PLA-1565] Scope fuel tank mutations (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored Jan 25, 2024
1 parent 89d84a0 commit 932af31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Enjin\Platform\FuelTanks\Enums\DispatchRule;
use Enjin\Platform\FuelTanks\GraphQL\Traits\HasFuelTankValidationRules;
use Enjin\Platform\FuelTanks\Rules\AccountsExistsInFuelTank;
use Enjin\Platform\FuelTanks\Rules\FuelTankExists;
use Enjin\Platform\FuelTanks\Rules\IsFuelTankOwner;
use Enjin\Platform\GraphQL\Schemas\Primary\Substrate\Traits\StoresTransactions;
use Enjin\Platform\GraphQL\Schemas\Primary\Traits\HasTransactionDeposit;
Expand Down Expand Up @@ -134,7 +133,6 @@ protected function rules(array $args = []): array
'filled',
'max:255',
new ValidSubstrateAddress(),
new FuelTankExists(),
new IsFuelTankOwner(),
],
'userId' => [
Expand Down
4 changes: 3 additions & 1 deletion src/Rules/IsFuelTankOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class IsFuelTankOwner implements DataAwareRule, ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$fuelTank = FuelTank::with('owner')->firstWhere('public_key', SS58Address::getPublicKey($value));
$fuelTank = FuelTank::where('public_key', SS58Address::getPublicKey($value))
->with('owner')
->first();
if (!$fuelTank) {
$fail(__('validation.exists', ['attribute' => $attribute]))->translate();

Expand Down

0 comments on commit 932af31

Please sign in to comment.