XF 2.3 Entity Relations

Lee

Well-known member
Can somebody please help me understand what I have done wrong here?

I have the following class extension saved in LifeSpot/ThreadSummary/XF/Entity/Thread.php:

PHP:
<?php
namespace LifeSpot\ThreadSummary\XF\Entity;
use XF\Mvc\Entity\Structure;
use XF\Mvc\Entity\Entity;
class Thread extends XFCP_Thread
{
    public static function getStructure(Structure $structure)
    {
        $structure = parent::getStructure($structure);
        $structure->relations['Summary'] = [
            'entity' => 'LifeSpot\ThreadSummary:Summary',
            'type' => self::TO_ONE,
            'conditions' => 'thread_id',
            'primary' => true
        ];
        return $structure;
    }
}

and the entity it is referencing:

PHP:
<?php

namespace LifeSpot\ThreadSummary\Entity;

use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;

class Summary extends Entity
{
    public static function getStructure(Structure $structure)
    {
        $structure->table = 'xf_thread_summaries';
        $structure->shortName = 'LifeSpot\ThreadSummary:Summary';
        $structure->primaryKey = 'thread_id';
        $structure->columns = [
            'thread_id' => ['type' => self::UINT, 'required' => true],
            'summary' => ['type' => self::STR, 'nullable' => true, 'default' => null],
            'last_updated' => ['type' => self::UINT, 'default' => \XF::$time],
        ];
        $structure->relations['Thread'] = [
            'entity' => 'XF:Thread',
            'type' => self::TO_ONE,
            'conditions' => 'thread_id',
            'primary' => true
        ];

        return $structure;
    }
}

When I dump variables and look for the relations to $thread there aren't any, I have record in the summary table.... any ideas?

EDITED to say there is a class extension registered in the ACP:

1742748501178.webp
 
When I dump variables and look for the relations to $thread there aren't any
What are you expecting to see exactly, and what are you actually seeing? Have you eager-loaded the relation? Did you dump $thread->Summary?
 
Back
Top Bottom