I'm not completely understanding what your question is, but you can use the collection keyBy
method for things like this.
// Get all of the user's profile data. Set key of these by using the keyBy method.
$userProfiles = Profile::where('user_id', '=', 1)->get()->keyBy('field');
// Because we set the key by the field value, you can now access them in several ways
echo $userProfiles['facebook']->value; // echoes out 'myfbusername'
echo $userProfiles->get('facebook')->value; // echoes out 'myfbusername'
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community