selectedYear = $today->format('Y'); $this->selectedMonth = $today->format('m'); $this->selectedDay = $today->format('d'); } public function render() { $query = Historiale::with('vendedor', 'tarifa', 'promocion'); if (!empty($this->servicio_id)) { $query = $query->whereHas('tarifa', function ($q) { $q->where('servicio_id', $this->servicio_id); }); } if ($this->selectedYear) { $query = $query->whereYear('fecha_inicio', $this->selectedYear); } if ($this->selectedMonth) { $query = $query->whereMonth('fecha_inicio', $this->selectedMonth); } if ($this->selectedDay) { $query = $query->whereDay('fecha_inicio', $this->selectedDay); } if ($this->promocion) { $query = $query->whereNotNull('promocion_id'); } else { $query = $query->whereNotNull('tarifa_id'); } if ($this->rol_id) { $query = $query->whereHas('vendedor', function ($q) { $q->where('rol_id', $this->rol_id); }); } $query = $query->where('estado', 'activo')->orderByDesc('created_at')->get(); return view('livewire.show-utilidades', [ 'historiales' => $query, 'servicios' => Servicio::where('estado', 'activo')->get(), 'roles' => Role::get(), ]); } }