Laravel hasOne through a pivot table
问题 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