Skip to content

Commit

Permalink
#1660 fixed issue with recommendation value setting
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jan 26, 2025
1 parent 15db26a commit 3771c1a
Showing 1 changed file with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ReviewerRecommendation extends Model
*/
protected $guarded = [
'recommendation_id',
'recommendationId',
'value',
];

/**
Expand Down Expand Up @@ -122,26 +124,11 @@ public function getMultilingualProps(): array
protected function value(): Attribute
{
return Attribute::make(
set: function (?int $value) {
set: function () {
if ($this->getRawOriginal('value')) {
return $this->getRawOriginal('value');
}

if ($value) {
$existingRecommendation = static::query()
->withContextId($this->contextId)
->where('value', $value)
->exists();

if ($existingRecommendation) {
throw new Exception(
"Given recommendation value : {$value} already exist for given context"
);
}

return $value;
}

$lastRecommendationValue = static::query()
->withContextId($this->contextId)
->when(
Expand Down

0 comments on commit 3771c1a

Please sign in to comment.