batch_id == '') { $voucher->batch_id = Str::ulid(); } if ($voucher->price == '') { $price = $voucher->display_price; if ($voucher->discount > 0) { $price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2); } $voucher->price = $price; } }); static::updating(function (Voucher $voucher) { $price = $voucher->display_price; if ($voucher->discount > 0) { $price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2); } $voucher->price = $price; }); } public function displayQuota(): Attribute { return Attribute::make(get: function () { return round($this->quota / (1024 * 1024 * 1024), 2) . ' GB'; }); } public function location() { return $this->belongsTo(Location::class); } }