gonziis - 4 months ago

When defining fields for my module like this

'decision_type_category' => [
            'type' => 'anomaly.field_type.relationship',
            'config' => [
                'title_name' => 'title',
                'related' => 'Mendo\DecisionsModule\DecisionTypeCategory',
            ],
        ],
        'case_classification' => [
            'type' => 'anomaly.field_type.relationship',
            'config' => [
                'title_name' => 'title',
                'related' => CaseClassificationModel::class,
            ],
        ],

It shows an error that the class was not found. I tried both ways of telling which model, but both show the error. An exception has been thrown during the rendering of a template ("An exception has been thrown during the rendering of a template ("An exception has been thrown during the rendering of a template ("Class DecisionTypeCategoryModel does not exist").")."). But the stream/model actually exists, I can go to src/DecisionTypeCategory/DecisionTypeCategoryModel.php and actually see the class being created. That's a weird problem, also the error seems to be recursed or something.

ryanthompson - 4 months ago

Pretty straight forward error here. The class does not exist as it says! Which can be tough but again with the IDE hinting it should help you narrow down the issue. Your fields look fine. Though I usually try and make a habit to use the string class (not the Class::class) in case the model doesn't indeed exist yet. You can also define related like namespace.stream_slug as well.

gonziis - 4 months ago

But how can it not exist? Where should it exist? Because when I go to my modules src/DecisionTypeCategory/DecisionTypeCategoryModel.php There actually is a code for defining the exact class.

<?php namespace Mendo\DecisionsModule\DecisionTypeCategory;

use Mendo\DecisionsModule\DecisionTypeCategory\Contract\DecisionTypeCategoryInterface;
use Anomaly\Streams\Platform\Model\Decisions\DecisionsDecisionTypeCategoriesEntryModel;

class DecisionTypeCategoryModel extends DecisionsDecisionTypeCategoriesEntryModel implements DecisionTypeCategoryInterface
{

}

This is confusing as hell. I know the error is straight forward, but it isn't because the class should exist. Maybe there is some old cache or something? Because that is a simple module and everything should work automatically, but I can't even go to @create without error.