I'm using Ormauth, I need to use the Auth_User model in my application and related to other models. I know the EVA model that it uses but I find it better to use a different model to maintain extra information related to the user. For example I have Profile model that has extra information, like first_name, last_name, address etc. I also have other models that directly relate to the Auth_User model, so how do I do it?
Do I go down to the ORM package and edit the Auth_User model itself or is there a better way to do it?
I did try something like that just extended Auth_User model with a class called User and used to get that EVA error you just mentioned. Thanks a lot for the help, as usual!
I just tried out your suggestion it works but I can't access newly defined methods and variables. For example in my new Auth_User class, I have the method with the following signature,
public static function get_picture($user, $type)
When I try to call that method, I'm getting the following error:
Fuel\Core\FuelException [ Error ]: Invalid method call. Method get_picture does not exist.
What does it mean? Can I not add functions and properties to the newly extended class? How do I fix this problem?
That's not working for me here is what I'm getting
Fuel\Core\FuelException [ Error ]: Invalid method call. Method get_picture does not exist.
PKGPATH/orm/classes/model.php @ line 636
Looks like it's searching for the method in the original Auth_User class, but I've added the class that extends the Auth_User class in my application as you've pointed out earlier but it doesn't seem to work.
That is exactly what I was thinking, I should have done that in order to override the original Auth_User class. Although, that was not exactly what I want to do, it's a great tip to keep in mind for the future.
I actually made changes to the new model, I put it in app/classes/model/user.php and defined my class as follows:
class Model_User extends Auth\Model\Auth_User {
...
}
Then I copy and pasted the existing Auth relationships since I'm only going to adding to those. I can now access my EVA attributes. Next thing to check is if I can relate the model to another model and be able to access it.
You also have to do that if you extend the original class. Point is that if you request Model\Auth_User, it loads your version instead of the original one.
If you make a derived class, like you do now, note that it works only in your controller, all Auth code will continue the original model. Also, since ORM caches objects, you might increase the load on the system because it will not be able to utilize the cache, as a Model\Auth_User object is not a Model_User object, even though it maps to the same record.