attendances = $attendances; $this->groupBy = $groupBy; $this->groupedValue = $groupedValue; } public function view(): View { return view('user.attendances_table', ['attendances_list' => $this->attendances, 'export' => 1]); } public function title(): string { if($this->groupBy == 'classes_id') { $subject = Subject::find(Classes::find($this->groupedValue)->subject_id)->name; $date = Classes::find($this->groupedValue)->date; $this->groupedValue = "{$date} {$subject}"; } return substr(str_replace(":", "-", "{$this->groupedValue}"), 0, 30); } }