app->make(Navigation::class)->add('kleinanzeigen', 'Kleinanzeigen', '/kleinanzeigen', active: 'kleinanzeigen.*', sort: 78); $this->app->make(Abilities::class)->define('kleinanzeigen.moderate', 'Kleinanzeigen freigeben und moderieren', 'Kleinanzeigen', portal: true); $this->app->make(GlobalSearch::class)->add('kleinanzeigen', 'Kleinanzeigen', 'shopping-bag', function (User $user, string $search, int $limit) { $query = Listing::query()->visible(); GlobalSearch::whereTerms($query, ['title', 'description', 'location'], $search); return $query->latest('published_at')->limit($limit)->get()->map(fn (Listing $l) => [ 'title' => $l->title, 'url' => '/kleinanzeigen/'.$l->id, 'excerpt' => GlobalSearch::excerpt($l->description, $search), 'meta' => collect([Listing::TYPES[$l->type], $l->priceLabel(), $l->location])->filter()->implode(' · '), ])->all(); }, sort: 70); // Startseite: die neuesten Anzeigen $this->app->make(Widgets::class)->add('kleinanzeigen.latest', 'kleinanzeigen::Latest', 'aside', sort: 40, props: function () { $listings = Listing::query()->visible()->with('images')->latest('published_at')->limit(4)->get(); return $listings->isEmpty() ? null : ['listings' => $listings->map(fn (Listing $l) => Presenter::card($l))->all()]; }, label: 'Kleinanzeigen', mobileSort: 45); // Redaktion: was auf Freigabe wartet $this->app->make(Editorial::class)->add('kleinanzeigen', 'Kleinanzeigen', 'kleinanzeigen::EditorialListings', 36, fn (User $user) => $user->can('kleinanzeigen.moderate'), fn () => ['pending' => Listing::query()->where('status', 'pending')->with('images')->oldest('updated_at')->limit(20)->get()->map(fn (Listing $l) => Presenter::card($l))->all()]); // Ab Inhaus 0.42.0: Symbol, offene Freigaben als Zahl und „Neu anlegen“ in der Redaktion $editorial = $this->app->make(Editorial::class); if (method_exists($editorial, 'meta')) { $editorial->meta('kleinanzeigen', icon: 'shopping-bag', todo: function () { $count = Listing::query()->where('status', 'pending')->count() + DB::table('kleinanzeigen_reports')->whereNull('resolved_at')->distinct()->count('listing_id'); return ['count' => $count, 'label' => $count === 1 ? 'Anzeige zu prüfen' : 'Anzeigen zu prüfen']; }, create: fn () => ['label' => 'Anzeige aufgeben', 'href' => route('kleinanzeigen.create')]); } if (class_exists(Digest::class)) { $this->app->make(Digest::class)->add('kleinanzeigen', 'Neue Kleinanzeigen', 60, fn (User $user, CarbonImmutable $since) => Listing::query() ->visible()->where('published_at', '>=', $since)->latest('published_at')->limit(6)->get() ->map(fn (Listing $l) => ['title' => $l->title, 'url' => route('kleinanzeigen.show', $l), 'meta' => collect([Listing::TYPES[$l->type], $l->priceLabel()])->filter()->implode(' · ')])->all()); } } public function boot(): void { Schedule::call(fn () => $this->app->make(Market::class)->housekeeping())->dailyAt('06:10')->name('kleinanzeigen-housekeeping')->withoutOverlapping(30); } public function uninstall(): void { Storage::disk(Photos::DISK)->deleteDirectory('kleinanzeigen'); } }