diff --git a/app/Controllers/CurrencyController.php b/app/Controllers/CurrencyController.php index b4e51e52..d0023082 100644 --- a/app/Controllers/CurrencyController.php +++ b/app/Controllers/CurrencyController.php @@ -91,7 +91,7 @@ protected static function makeUpdateValidation(User $owner, int $resource_id): V "code->$individual_name.code", "user_id=$user_id" ]), - "id=$id" + "id=$resource_id" ])."]" ]); diff --git a/app/Controllers/FinancialEntryController.php b/app/Controllers/FinancialEntryController.php index 1eb444e3..7319d421 100644 --- a/app/Controllers/FinancialEntryController.php +++ b/app/Controllers/FinancialEntryController.php @@ -2,6 +2,7 @@ namespace App\Controllers; +use CodeIgniter\Shield\Entities\User; use CodeIgniter\Validation\Validation; use App\Contracts\OwnedResource; @@ -24,7 +25,7 @@ protected static function getModelName(): string { return FinancialEntryModel::class; } - protected static function makeCreateValidation(): Validation { + protected static function makeCreateValidation(User $owner): Validation { $validation = static::makeValidation(); $individual_name = static::getIndividualName(); @@ -53,7 +54,7 @@ protected static function makeCreateValidation(): Validation { return $validation; } - protected static function makeUpdateValidation(int $id): Validation { + protected static function makeUpdateValidation(User $owner, int $resource_id): Validation { $validation = static::makeValidation(); $individual_name = static::getIndividualName(); @@ -63,7 +64,7 @@ protected static function makeUpdateValidation(int $id): Validation { "min_length[1]", "max_length[255]", "numeric", - "must_be_same_for_financial_entry[$id,$individual_name.credit_amount]" + "must_be_same_for_financial_entry[$resource_id,$individual_name.credit_amount]" ]); return $validation; diff --git a/app/Controllers/FrozenPeriodController.php b/app/Controllers/FrozenPeriodController.php index 4773f161..b4685b1d 100644 --- a/app/Controllers/FrozenPeriodController.php +++ b/app/Controllers/FrozenPeriodController.php @@ -4,6 +4,7 @@ use Brick\Math\BigRational; use CodeIgniter\I18n\Time; +use CodeIgniter\Shield\Entities\User; use CodeIgniter\Validation\Validation; use App\Casts\ModifierAction; @@ -31,11 +32,11 @@ protected static function getModelName(): string { return FrozenPeriodModel::class; } - protected static function makeCreateValidation(): Validation { + protected static function makeCreateValidation(User $owner): Validation { return static::makeValidation(); } - protected static function makeUpdateValidation(int $id): Validation { + protected static function makeUpdateValidation(User $owner, int $resource_id): Validation { return static::makeValidation(); } @@ -182,14 +183,13 @@ protected static function calculateValidSummaryCalculations( public function dry_run_create() { + $current_user = auth()->user(); $controller = $this; - $validation = $this->makeCreateValidation(); + $validation = $this->makeCreateValidation($current_user); return $this ->useValidInputsOnly( $validation, - function($request_data) use ($controller) { - $current_user = auth()->user(); - + function($request_data) use ($controller, $current_user) { $model = static::getModel(); $info = static::prepareRequestData($request_data); [