Loheide-eu-mitarbeiterplatt.../plugins-core/stellen/src/JobSearch.php
Friederich Loheide 993d49c99c
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m1s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m42s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m37s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m43s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Neues Modul Interne Stellenausschreibungen (0.28.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 10:16:48 +00:00

27 lines
932 B
PHP

<?php
namespace Inhaus\Plugins\Stellen;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Stellen\Models\JobPosting;
/** Suchquelle: offene Stellen */
class JobSearch
{
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = JobPosting::query()->open();
GlobalSearch::whereTerms($query, ['title', 'department', 'location', 'description'], $search);
return $query->orderByDesc('published_at')->limit($limit)->get()->map(fn (JobPosting $p) => [
'title' => $p->title,
'url' => '/stellen/'.$p->id,
'excerpt' => GlobalSearch::excerpt(strip_tags((string) $p->description), $search),
'meta' => collect([$p->department, $p->location, $p->deadline ? 'Frist '.$p->deadline->format('d.m.Y') : null])->filter()->implode(' · '),
])->all();
}
}