. */ /** * An interface to the discount table in the database */ class Discount extends Model implements Calculatable { use StandardCalculatable; public $table = 'discount', $fillable_columns = ['offerId', 'title', 'description', 'value', 'VAT_percentage']; /** * Get the offer that this discount is linked to * * @return offer The offer */ public function getOffer() { return new Offer($this->pdo, $this->offerId); } /** * The description after having parsed markdown * * @return string The description in HTML format */ public function getHTMLDescription() { $pd = new Parsedown; return $pd->text($this->description); } public function calculateSubtotal() { return - $this->value; } public function calculateVAT() { return $this->calculateSubtotal() * $this->VAT_percentage / 100; } }