From 932af31313dc97b8924bfee34d6bd17c22b2c3e1 Mon Sep 17 00:00:00 2001 From: Abner Tudtud <114082473+enjinabner@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:35:50 +0800 Subject: [PATCH] [PLA-1565] Scope fuel tank mutations (#33) --- src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php | 2 -- src/Rules/IsFuelTankOwner.php | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php b/src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php index 75245e3..0b35038 100644 --- a/src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php +++ b/src/GraphQL/Mutations/RemoveAccountRuleDataMutation.php @@ -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; @@ -134,7 +133,6 @@ protected function rules(array $args = []): array 'filled', 'max:255', new ValidSubstrateAddress(), - new FuelTankExists(), new IsFuelTankOwner(), ], 'userId' => [ diff --git a/src/Rules/IsFuelTankOwner.php b/src/Rules/IsFuelTankOwner.php index 92576c6..017866c 100644 --- a/src/Rules/IsFuelTankOwner.php +++ b/src/Rules/IsFuelTankOwner.php @@ -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();