Example: I have following two classes for tables in database.
class Post extends Model {}
class User extends Model {
public function posts() {
return $this->has_many('Post'); // Note we use the model name literally - not a pluralised version
}
}
Now I want to quert all users and their associated posts in one variable. something like that:
$user = Model::factory('User')->find_many();
// Find the posts associated with the user
$posts = $user->posts()->find_many();
I want to get the result in $posts variable.