Skip to content

Commit

Permalink
Check for valid preset before assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
cholladay0816 committed Sep 6, 2023
1 parent c7eef8f commit 9b47e5d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/Models/Commission.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,13 @@ protected static function boot()
{
self::creating(function ($commission) {
if ($commission->commission_preset_id != null) {
$preset = $commission->preset;
$commission->title = $preset->title;
$commission->description = $preset->description;
$commission->price = $preset->price;
$commission->days_to_complete = $preset->days_to_complete;
$preset = CommissionPreset::find($commission->commission_preset_id);
if($preset) {
$commission->title = $preset->title;
$commission->description = $preset->description;
$commission->price = $preset->price;
$commission->days_to_complete = $preset->days_to_complete;
}
}
$commission->slug = $commission->getSlug();
});
Expand Down

0 comments on commit 9b47e5d

Please sign in to comment.