autors overview

This commit is contained in:
HolgerHatGarKeineNode
2023-03-15 16:07:57 +01:00
parent 3da39e240f
commit 5f677d3a2c
17 changed files with 171 additions and 12 deletions

View File

@@ -13,6 +13,12 @@ class ArticleOverview extends Component
use Actions;
use NostrTrait;
public array $filters = [];
protected $queryString = [
'filters' => ['except' => ''],
];
public function nostr($id)
{
$libraryItem = LibraryItem::query()
@@ -56,6 +62,11 @@ class ArticleOverview extends Component
$this->emit('$refresh');
}
public function resetFiltering()
{
return to_route('article.overview');
}
public function render()
{
return view('livewire.news.article-overview', [
@@ -65,6 +76,11 @@ class ArticleOverview extends Component
'lecturer',
'tags',
])
->when(
isset($this->filters['author']),
fn($query) => $query->whereHas('lecturer',
fn($query) => $query->where('lecturers.slug',
$this->filters['author'])))
->where('type', 'markdown_article')
->where('news', true)
->orderByDesc('created_at')

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Livewire\News;
use App\Models\Lecturer;
use Livewire\Component;
class AuthorsOverview extends Component
{
public function render()
{
return view('livewire.news.authors-overview', [
'authors' => Lecturer::query()
->whereHas('libraryItems', function ($query) {
$query->where('library_items.news', true);
})
->withCount([
'libraryItems' => fn($query) => $query->where('library_items.news', true),
])
->get(),
]);
}
}