XF 2.0 relations in finder

canina

Active member
I created a new table and I want to make it a new and separate entity

This code is:

Finder
PHP:
namespace BoardOfProfessionals\Repository;

use XF\Mvc\Entity\Finder;
use XF\Mvc\Entity\Repository;

class BOPClassifications extends Repository
{
    /**
     * @return Finder
     */
    public function findClassificationsForBoardOfProfessionalsView()
    {

        $finder = $this->finder('BoardOfProfessionals:BOPClassifications');
        $finder
            ->setDefaultOrder('classification_id', 'DESC')
       
            ->with('BOPClassifications.classification_id')
        //    ->with('BOPClassifications.Classifications')
            ->with('BOPClassifications.Turning_to');

        return $finder;
    }
}

Entity

PHP:
namespace BoardOfProfessionals\Entity;

use XF\Mvc\Entity\Structure;

class BOPClassifications extends \XF\Mvc\Entity\Entity
{
    public static function getStructure(Structure $structure)
    {
        $structure->table = 'xf_BoardOfProfessionals_Classifications';
        $structure->shortName = 'XF:BOPClassifications';
        $structure->primaryKey = 'classification_id';
        $structure->columns = [
            'classification_id' => ['type' => self::UINT, 'required' => true],
           // 'Classifications' => ['type' => Entity::SERIALIZED_ARRAY, 'default' => array("id"=> 5,"text" => 'ab)],
            'Turning to' => ['type' => self::UINT, 'default' => 0]
        ];
        $structure->getters = [];
        $structure->relations = [
            'BOPClassifications' => [
                'entity' => 'BOPClassifications',
                'type' => self::TO_ONE,
                'conditions' => 'classification_id',
                'primary' => true
            ],
        ];
     

        return $structure;
    }

 
}

But there is a mistake in the $structure->relations
This is the fourth line in error

198104
 
Last edited:
Back
Top Bottom