芝麻web文件管理V1.00
编辑当前文件:/home/forge/stage.sksb.smartcon-survey.com/app/Livewire/Comments.php
comments = $this->filterComments($this->limit)->get(); } public function updatedPickedMonths(): void { $this->comments = $this->filterComments($this->limit)->get(); } private function filterComments(int $limit = 10): Builder { $comments = Comment::where('show', 1) ->orderBy('comments.created_at', 'desc'); if ($this->pickedTopic > 0) { $comments = $comments->whereHas('assignedTopics', fn ($query) => $query->where('topic_id', $this->pickedTopic)); } if (! empty($this->pickedMonths)) { $comments = $comments->whereInDateRange($this->pickedMonths); } if ($limit > 0) { $comments = $comments->limit($limit); } return $comments; } public function render(): View { $this->months = (new MonthFilter)->months(); $this->topics = Topic::select(['id', 'name'])->get()->all(); $this->comments = $this->filterComments($this->limit)->get(); return view('livewire.comments'); } public function showMore(): void { $this->limit += 10; } public function downloadExcel(): BinaryFileResponse { $collection = $this->comments->map(function ($item) { return $item->only(['text', 'topic', 'created_at']); }); $collection = $collection->map(function ($item) { $item['topic'] = $item['topic']->name; return $item; }); return $collection->downloadExcel('Offene_Antworten.xlsx'); } public function restoreComment(int $id): RedirectResponse|Redirector { Comment::restoreComment($id); session()->flash('comment_success', 'Das Antwort wurde erfolgreich zurückgeholt.'); return redirect(route('dashboard.comments')); } }