Profilseite: Kommentare der Person
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53df8918f6
commit
8a59023569
118 changed files with 620 additions and 438 deletions
|
|
@ -11,6 +11,7 @@ use App\Pagebuilder\Blocks;
|
|||
use App\Pagebuilder\BlockType;
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Profile\ProfilePanels;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
|
|
@ -18,8 +19,10 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\News\Http\Resources\NewsPostResource;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsComment;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Inhaus\Plugins\News\Policies\NewsCategoryPolicy;
|
||||
use Inhaus\Plugins\News\Policies\NewsPostPolicy;
|
||||
|
|
@ -43,6 +46,28 @@ class NewsPlugin extends Plugin
|
|||
Gate::policy(NewsPost::class, NewsPostPolicy::class);
|
||||
|
||||
$this->registerWidgets($this->app->make(Widgets::class));
|
||||
|
||||
// Profilseite: Kommentare der Person – nur zu Beiträgen, die die betrachtende Person sehen darf
|
||||
$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));
|
||||
$total = (clone $query)->count();
|
||||
|
||||
if ($total === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'total' => $total,
|
||||
'comments' => $query->with('post:id,title,slug')->latest()->limit(8)->get()->map(fn (NewsComment $comment) => [
|
||||
'id' => $comment->id,
|
||||
'excerpt' => Str::limit($comment->body, 180),
|
||||
'is_reply' => $comment->parent_id !== null,
|
||||
'created_at' => $comment->created_at?->toIso8601String(),
|
||||
'post' => ['title' => $comment->post->title, 'url' => route('news.show', $comment->post).'#kommentar-'.$comment->id],
|
||||
])->all(),
|
||||
];
|
||||
});
|
||||
$this->registerMediaUsages($this->app->make(MediaUsages::class));
|
||||
|
||||
$this->app->make(Editorial::class)->add(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue