So I have 2 models, User & Profile, the relationship is set up as follows:
/**
* User belongs to many Profile
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function profiles()
{
return $this->belongsToMany('App\Models\Profile', 'user_profiles');
}
I have 3 tables, users, profiles & user_profiles (the pivot table)
I have a column in my users table called active_profile
which gets populated with a profile id.
How can I set up the relationship so that I can call something like the following:
$user->active_profile
So that it will return all the profile information for the id set in active_profile?