Skip to content

Commit

Permalink
fix(controller): correct compliance to abstract owned controller
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 23, 2023
1 parent 1871ff9 commit a11167c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Controllers/CurrencyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
])."]"
]);

Expand Down
7 changes: 4 additions & 3 deletions app/Controllers/FinancialEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Controllers;

use CodeIgniter\Shield\Entities\User;
use CodeIgniter\Validation\Validation;

use App\Contracts\OwnedResource;
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions app/Controllers/FrozenPeriodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
[
Expand Down

0 comments on commit a11167c

Please sign in to comment.