Accessor will do the job:
// User model
public function getMetadataAttribute()
{
return $this->usermeta->lists('meta_value','meta_key');
}
// call:
$user->usermeta;
This will load the relation if needed, and use existing collection if it's loaded already.
If I'm accessing this multiple times, won't that cause it to have to rebuild the array over and over?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community