Skip to content

Commit

Permalink
[BF] could not save associate member edits due to int/string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jan 16, 2022
1 parent 452fcb1 commit b707e00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Customer/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function edit( Request $r, Customer $cust ): View
'shortname' => $r->old( 'shortname', $cust->shortname ),
'corpwww' => $r->old( 'corpwww', $cust->corpwww ),
'datejoin' => $r->old( 'datejoin', !$cust->datejoin ?: $cust->datejoin->format( "Y-m-d" ) ) ,
'dateleave' => $r->old( 'dateleave', !$cust->dateleave ?: $cust->dateleave->format( "Y-m-d" ) ),
'dateleave' => $r->old( 'dateleave', !$cust->dateleave ?: $cust->dateleave->format( "Y-m-d" ) ),
'status' => $r->old( 'status', $cust->status ),
'MD5Support' => $r->old( 'MD5Support', $cust->MD5Support ),
'abbreviatedName' => $r->old( 'abbreviatedName', $cust->abbreviatedName ),
Expand Down
8 changes: 5 additions & 3 deletions app/Http/Requests/Customer/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function rules(): array
'type' => 'required|integer|in:' . implode( ',', array_keys( Customer::$CUST_TYPES_TEXT ) ),
'shortname' => 'required|string|max:30|regex:/[a-z0-9]+/|unique:cust,shortname'. ( $this->cust ? ','. $this->cust->id : '' ),
'corpwww' => 'nullable|url|max:255',
'datejoin' => 'date',
'datejoin' => 'required|date',
'dateleft' => 'nullable|date',
'status' => 'required|integer|in:' . implode( ',', array_keys( Customer::$CUST_STATUS_TEXT ) ),
'md5support' => 'nullable|string|in:' . implode( ',', array_keys( Customer::$MD5_SUPPORT ) ),
Expand All @@ -87,7 +87,7 @@ public function rules(): array
'reseller' => 'nullable|integer|exists:cust,id',
];

return $this-> type === Customer::TYPE_ASSOCIATE ? $validateCommonDetails : array_merge( $validateCommonDetails, $validateOtherDetails ) ;
return $this->type == Customer::TYPE_ASSOCIATE ? $validateCommonDetails : array_merge( $validateCommonDetails, $validateOtherDetails ) ;
}

/**
Expand All @@ -100,7 +100,9 @@ public function rules(): array
public function withValidator( Validator $validator ): void
{
$validator->after( function( $validator ) {
$this->checkReseller( $validator );
if( $this->type != Customer::TYPE_ASSOCIATE ) {
$this->checkReseller( $validator );
}
});
}

Expand Down

0 comments on commit b707e00

Please sign in to comment.