// get the meta data for user 1: if ($user = \Model\Auth_User::find(1, array('related' => 'metadata'))) { $metatdata = \Arr::pluck($user->metadata, 'key', 'value'); } else { // user not found }
I though you wanted all meta fields of a single user, not the same field from all users.
Since you need the metadata for each user, include it in the query. You are lazy loading the data, which means it will run a query to get the meta data for every user. With 1000 users, your code runs 1001 queries. Better use
It's always handy to have the profiler active when you develop your application, you can easily see the effect a code change has on the performance, the database I/O, the memory usage, etc.