Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
One to Many in package model extend to app model?
  • I'm trying to add a one to many relationship to the \Warden\Model_User - I tried extending it in my APP model. <code>
    class Model_User extends \Warden\Model_User
    {
    protected static $_has_many = array(
    "properties" // reference to Model_Property
    );
    }
    </code> But when the ORM gets down to the Warden package it cannot find my app's Model_Property and is throwing an OutOfBoundsException. errors below OutOfBoundsException [ Error ]: Property "properties" not found for Warden\Model_User. PKGPATH/orm/classes/model.php @ line 806
    PKGPATH/warden/classes/warden/model/user.php @ line 179
    APPPATH/classes/controller/test/property.php @ line 15
    COREPATH/classes/request.php @ line 420
    DOCROOT/index.php @ line 38
  • This error is probably generated by the Warden code itself, which runs in the \Warden namespace. Because you haven't defined the 'model_to' in your relation, it will probably try to find Model_Property in the \Warden namespace, and not in global. Try this:
    protected static $_has_many = array(
        "properties" => array(
            "model_to" => '\\Model_Property',
        ),
     ;
    

    This is off course assuming that the Warden code is written so that you can extend it this way. If it contains code that assumes that all properties are table columns, you might have more issues implementing this.
  • Thank you so much! It works!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion