I have a Many-to-Many relationship where there is an addional value column on the table. How do I pick that value? So...
pivot_table
- user_id
- something_id
- value
Model User
:
return $this->belongsToMany('Something', 'user_something')->withPivot('value');
Now, I would like to get the value for one user where the something id is 2.
Something like this:
$user = User::find(1);
$user->something->whereSomethingId(2)->pivot->value;