'int', 'service_provider_id' => 'int', 'amount' => 'float', 'amount_eur' => 'float', 'factor' => 'float', 'is_cleared' => 'bool' ]; protected $dates = [ 'payment_date' ]; protected $fillable = [ 'booking_id', 'service_provider_id', 'amount', 'amount_eur', 'factor', 'payment_date', 'invoice_number', 'is_cleared', 'type' ]; private static $counter = 0; private static $bookingIds = array(); public function booking() { return $this->belongsTo(Booking::class); } public function service_provider() { return $this->belongsTo(ServiceProvider::class); } public function getCounter(){ if ($this->booking_id) { if (!in_array($this->booking_id, self::$bookingIds)) { self::$bookingIds[] = $this->booking_id; self::$counter++; } return self::$counter; } } public function getAmountFinalEur(){ $ret = $this->amount; if($this->amount_eur && $this->amount_eur > 0){ $ret = $this->amount_eur; } return number_format($ret, 2, ',', '.'); } public function getAmountFinalEurRaw(){ if($this->amount_eur && $this->amount_eur > 0){ return $this->amount_eur; } return $this->amount; } public function getPaymentDateFormat(){ if(!$this->attributes['payment_date']){ return ""; } return Carbon::parse($this->attributes['payment_date'])->format(\Util::formatDateDB()); } }