Another fix for dates when using addMonth()

This commit is contained in:
Deon George
2021-03-12 22:59:19 +11:00
parent 45c93283fb
commit b01976a6ae
2 changed files with 2 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ class AdslTraffic extends Model
public function getTrafficMonthEndAttribute() {
if ($this->date->day > $this->traffic_end) {
// If we are the last day of the month, we'll temporarily take 3 days since Jan 31 and addMonth() results in March.
if ($this->date->isLastOfMonth())
if ($this->date->addMonth()->day != $this->date->day)
$this->date=$this->date->subDays(3);
return Carbon::createFromFormat('Y-m-d',$this->date->addMonth()->format('Y-m-').$this->traffic_end);