Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
post_find for ORM Model
  • Is there a post_find equivalent for \Orm\Model? 

    I'm trying to find a clean way to manipulate an object returned by a find, in this specific case, to just give me easy access to $user->fullname as a concatenation of $user->firstname . " " . $user->lastname for use in my views. I'd like to keep this kind of thing out of the controller.

    I've tried overriding the find method in my model to add the extra after calling parent::find but this didn't work.

    Thanks
  • I should have mentioned, I'm using 1.4.
  • ORM doesn't use methods, it used observers, which are events that are triggered.

    In this case, you need to write an observer that captures the "after_load" event. It will be fired on the object, so for each object created in your find() result.
  • Got it, thanks Harro.

Howdy, Stranger!

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

In this Discussion