XF 2.0 PluckFrom a relationship?

Jaxel

Well-known member
Is it possible to pluckFrom a relationship? I'm getting getter warnings on this.
Code:
        $admins = $this->getAdminRepo()->findAdmin()
            ->where('league_id', $league->league_id)
            ->pluckFrom('User.username')
            ->fetch();
 
I think you'd have to use your own closure, based on the implementation:

PHP:
$admins = $this->getAdminRepo()->findAdmin()
            ->where('league_id', $league->league_id)
            ->pluckFrom(function(Admin $admin) {return $admin->User->username;})
            ->fetch();

Liam
 
Top Bottom