fuel / orm

Fuel PHP Framework - Fuel v1.x ORM
http://fuelphp.com/docs/packages/orm/intro.html
152 stars 96 forks source link

Orm\Model::related_class() and short (defaults) relations config #394

Closed scruwi closed 8 years ago

scruwi commented 8 years ago

If model relations fully configured, Orm\Model::related_class('profile') is working:

class Model_User extends Orm\Model
{
  protected static $_has_one = array(
      'profile' => array(
          'key_from' => 'id',
          'model_to' => 'Model_Profile',
          'key_to' => 'user_id',
          'cascade_save' => true,
          'cascade_delete' => false,
      )
  );
}
$rel_name = Model_User::related_class('profile'); // Model_Profile

but if there a short config - return NULL:

class Model_User extends Orm\Model
{
  `protected static $_has_one = array('profile');`
}
$rel_name = Model_User::related_class('profile'); // NULL