Profil zeigt geschriebene Beiträge, Als Person anmelden (0.27.1)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m40s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m51s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m36s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m40s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m51s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m36s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1469f50401
commit
546c94db1c
127 changed files with 643 additions and 337 deletions
|
|
@ -24,6 +24,7 @@ class NewsController extends Controller
|
|||
// Mehrere Kategorien bzw. alle außer bestimmten (Link „Alle Beiträge“ der Startseite)
|
||||
$list = fn (string $param) => $categories->whereIn('slug', array_filter(explode(',', (string) $request->query($param, ''))))->values();
|
||||
$only = $category ? collect() : $list('kategorien');
|
||||
$author = $request->integer('autor') ? User::query()->find($request->integer('autor')) : null;
|
||||
$without = $category ? collect() : $list('ohne');
|
||||
|
||||
$posts = NewsPost::query()
|
||||
|
|
@ -31,6 +32,7 @@ class NewsController extends Controller
|
|||
->visibleTo($request->user())
|
||||
->with('category')
|
||||
->when($category, fn ($query) => $query->where('category_id', $category->id))
|
||||
->when($author, fn ($query) => $query->where('author_id', $author->id))
|
||||
->when($only->isNotEmpty(), fn ($query) => $query->whereIn('category_id', $only->pluck('id')))
|
||||
->when($without->isNotEmpty(), fn ($query) => $query->where(fn ($q) => $q->whereNull('category_id')->orWhereNotIn('category_id', $without->pluck('id'))))
|
||||
->latest('published_at')
|
||||
|
|
@ -42,6 +44,7 @@ class NewsController extends Controller
|
|||
'categories' => $categories->map(fn (NewsCategory $c) => ['name' => $c->name, 'slug' => $c->slug]),
|
||||
'activeCategory' => $category?->slug,
|
||||
'filter' => match (true) {
|
||||
$author !== null => 'Von: '.$author->name,
|
||||
$only->isNotEmpty() => 'Nur: '.$only->pluck('name')->implode(', '),
|
||||
$without->isNotEmpty() => 'Ohne: '.$without->pluck('name')->implode(', '),
|
||||
default => null,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,18 @@ class NewsPlugin extends Plugin
|
|||
$this->registerWidgets($this->app->make(Widgets::class));
|
||||
|
||||
// Profilseite: Kommentare der Person – nur zu Beiträgen, die die betrachtende Person sehen darf
|
||||
// Profil: Beiträge, die die Person geschrieben hat
|
||||
$this->app->make(ProfilePanels::class)->add('news.posts', 'news::Posts', 10, function (User $person, User $viewer) {
|
||||
$query = NewsPost::query()->where('author_id', $person->id)->published()->visibleTo($viewer);
|
||||
$total = (clone $query)->count();
|
||||
|
||||
return $total === 0 ? null : [
|
||||
'total' => $total,
|
||||
'posts' => NewsPostResource::collection($query->with('category')->latest('published_at')->limit(4)->get())->resolve(),
|
||||
'all_url' => '/neuigkeiten?autor='.$person->id,
|
||||
];
|
||||
});
|
||||
|
||||
$this->app->make(ProfilePanels::class)->add('news.comments', 'news::Comments', 20, function (User $person, User $viewer) {
|
||||
$query = NewsComment::query()->where('user_id', $person->id)
|
||||
->whereHas('post', fn ($post) => $post->published()->visibleTo($viewer));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue