Skip to content

Commit

Permalink
fix(Orders): ensure products created that will be first of a category…
Browse files Browse the repository at this point in the history
… gracefully defaults to 0 as the starting sequence value.
  • Loading branch information
Patrick Mulligan committed Apr 26, 2024
1 parent bb3f941 commit 838c453
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/Modules/Orders/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ public static function boot(): void
// Set sequence value for new entries
if (!$model->id)
{
$sequence = self::query()
$sequenceModel = self::query()
->where('ordercategoryid', '=', $model->ordercategoryid)
->orderBy('sequence', 'desc')
->first()
->sequence;

->first();
$sequence = $sequenceModel->sequence ?? 0;
$model->sequence = intval($sequence) + 1;
}
});
Expand Down

0 comments on commit 838c453

Please sign in to comment.