public function getTotalPriceAttribute() { $dateRange = DateHelper::date_range($this->check_in, $this->check_out); $totalPrice = 0; $weekendPrice = $this->rate->weekend_price; $weekdayPrice = $this->rate->weekday_price; foreach ($dateRange as $date) { if (DateHelper::isWeekend($date)) { $totalPrice += $weekendPrice; } else { $totalPrice += $weekdayPrice; } } $services = $this->roomType->servicePlans->services; if ($services !== null) { foreach ($services as $service) { $totalPrice += $service->price; } } return $totalPrice; }