Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
relation with auth table
  • how i make a relation with users table using \Auth::users model ?

    protected static $_has_one = array('user');
  • You have to fully write it out, auto-detection doesn't detect namespaced models.

    protected static $_has_one = array('user => array(
        'model_to' => '\Auth\Model\Auth_User',
    )');


    and other parameters you may need...
  • I do it but don't work :-(

    protected static $_has_one = array(
       'user' => array(
           'key_from' => 'user_id',
           'model_to' => '\Auth\Model\Auth_User', 
           'key_to' => 'id',
           'cascade_save' => false,
           'cascade_delete' => false,
       )
    );
  • HarroHarro
    Accepted Answer
    Define "not work"? Error messages? Unexpected behavior?

    If I may guess: the model you define this on contains the column 'user_id', which is the foreign key of this relation. Which means this must be a belongs_to relation, not a has_one.

    Also, in certain situations you might have a problem with the return definition that is missing from the User model. If that is the case you need to overload it in the app, and add it (do not change the original in the package).
  • Ok now Works fine Thanks again Harro :-)

Howdy, Stranger!

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

In this Discussion