Laravel: Get pivot data for specific many to many relation

前端 未结 2 969
-上瘾入骨i
-上瘾入骨i 2020-12-03 02:44

My User model has many Target and vice versa. Now I\'ve got a given User and given Target and I want to access pivot data

2条回答
  •  独厮守ぢ
    2020-12-03 02:56

    You can also limit columns by passing array as 2nd arg to simplePaginate

    $query->users()->simplePaginate($per_page, ['users.id', 'users.email']);
    

提交回复
热议问题