Open tmsilva opened 7 years ago
Acredito que seja assim
class Example extends Model {
protected $table = 'examples';
protected $primaryKey = ['first_id', 'second_id'];
public $incrementing = false;
....
Na migration:
Schema::create('examples', function (Blueprint $table) { $table->integer('first_id')->unsigned(); $table->integer('second_id')->unsigned(); $table->text('other_column');
$table->primary(['first_id', 'second_id']);
$table->foreign('first_id')->references('id')->on('firsts');
$table->foreign('second_id')->references('id')->on('seconds');
});
Existe alguma solução para a utilização de composite primary key usando My sql e Laravel?