get(); } public function getForMap(): Collection { return Thema::with([ 'speerpunten.projects' => function ($q) { $q->with('eigenaar') ->withCount(['documents', 'commitments', 'risicos']); } ])->get(); } public function create(array $data): Thema { $thema = Thema::create([ 'naam' => $data['naam'], 'beschrijving' => $data['beschrijving'] ?? '', 'prioriteit' => $data['prioriteit'] ?? \App\Enums\Prioriteit::Midden, 'periode_start' => $data['periode_start'] ?? null, 'periode_eind' => $data['periode_eind'] ?? null, ]); AuditLog::create([ 'user_id' => Auth::id(), 'action' => 'thema.created', 'entity_type' => 'thema', 'entity_id' => $thema->id, ]); return $thema; } public function update(Thema $thema, array $data): Thema { $thema->update(array_filter($data, fn ($v) => $v !== null)); AuditLog::create([ 'user_id' => Auth::id(), 'action' => 'thema.updated', 'entity_type' => 'thema', 'entity_id' => $thema->id, ]); return $thema->fresh(); } }