I recently started using RedBean ORM.
I have a User bean type to store the user's info, and an associated FUSE model for user functionality.
When a user logs in, or a session is already set, Redbean retrieves the user's info including address.
Until a user has logged in, I set the state and city values for a fresh user bean via geoip location services.
I am wondering what the best practice is on this type of procedure.
The way I see it, I have a few options:
I'm guessing you don't really want to do option one, because it creates a dependency for the class.
Any thoughts?
If you need to process geoip stuff with user every time it loggs in - Create method and initialize it on user login (1). In other option I'd use option 3 (Instantiate the geoip object outside of the FUSE model, but pass the object to a FUSE model setter which knows how to handle it.
). It's better not to work with object properties directly and set some metods to handle these properties.
$user->setProperty('one'); // Actually can just execute `$user->property = $var;`
but not
$user->property = 'one';