Laravel 5.2与数据透视表的关系

my tables:

tables

  1. every part contain many of card.
  2. every card belong to many of part.

now,using laravel eloquent model how can fetch all card for a part without add more column to database

You need to define your relationships like below:

class Part extends Model
{
    public function cards()
    {
        return $this->belongsToMany('App\Cards', 'user_cards');
    }
}

Then you can fetch all the cards for a part like below:

$cards = Part::with('cards')->find($part_id);
Part::whereHas('cards', function($query) use ($cardId){
  $query->where('id', $cardId);  
})->get();

And your model relation should contain like this, for Part.php

public function cards(){ 
 return $this->belongsToMany('App\Card');    
}

And for Card.php

public function parts(){ 
 return $this->belongsToMany('App\Part');    
}