Show all projects of given service

Hi there once again, I was wondering if anyone could help me out there.

What I am after is that when I click the listed services on my project detail page, is that it goes to the services landing page, where you can see related projects following the same services.

project.yml

services:
            type: pages
            value: "{{ page.uuid }}"
            label: Assigned Services
            query: kirby.page("services").childrenAndDrafts

this is how it looks in my project.txt

Services:

- page://3MxSkFGTDDzRXn37
- page://CYLzwIK9TFdKP93B

----

what code do i need to display the projects assigned to that service? on my service.php

The detail service pages work perfectly, all the info i want on there is displaying, but now I would love to list all the projects that have that service.

 //this displays the service as: service/my-service
  $service = $page;
  //this displays the actual service title as my-service
  $serviceTitle = $service->title();
  // Fetch all projects and filter... but I can not get it to work
  $projects = site()->find('projects')->children()->listed()->filterBy('services', $service->title());
 // Fetch all projects  works fine
  $projects = site()->find('projects')->children()->listed();

Thank you for helping me out here.

I think you need to use uuid and not the title.
Did you tried to filter by uuid? Unique IDs & Permalinks | Kirby CMS

Maybe like here → Filter by uuid in pages field - #2 by texnixe

Thanks for your reply.
After many hours of trying to figure it out. I did… however I still do not know how I did it and what I did wrong first.

This code goes into the service-detail.php template

<!-- Get all the projects that use this service... -->
<?php
// Get the current service page
$service = $page;
$serviceTitle = $service->title();
// Fetch all projects that use this service
$projects = site()->find('projects')->children()->listed()->filter(function ($project) use ($serviceTitle) {
  // Check if the project's services field contains the service title
  return $project->services()->toPages()->has($serviceTitle);
});
?>

<h3>Projects that use this service</h3>
<?php if ($projects->isEmpty()): ?>
  <p>No projects found for this service.</p>
<?php else: ?>
  <ul>
    <?php foreach ($projects as $project): ?>
      <li>
          <a href="<?= $project->url() ?>">
            <?= $project->title() ?>
          </a>
      </li>
    <?php endforeach ?>
  </ul>
<?php endif; ?>