Search code examples
symfonyeasyadmin

get last value form ManyToMany


I have connected two tables "Status" and Service" with ManyToMany and I get all entries with the following field: yield ArrayField::new('lastStatus', 'Last Status')

But I would like to display only the last element. I tried it with end() but it tells me that it is not an array. What format is it and how can I manipulate this?


Solution

  • thank you Arleigh Hix I have found the following solution

    # src/Entity/Service.php
        public function getLastStatus()
        {
            return $this->getStatuses()->last();
        }
    

    yield TextField::new('lastStatus', 'Last Status')