-1
I have 3 tables
Sales
ID | TITULO
Brokers
ID | NOME
Relas - "Make the relationship between the tables"
ID | VENDAS_ID | CORRETORES_ID | TIPO
I need the table relas
make the relationship between the tables
I tried my model like this :
public function vendas()
{
return $this->belongsToMany(Vendas::class);
}
public function corretores()
{
return $this->belongsToMany(Corretores::class);
}
My model sales like this:
public function relas()
{
return $this->hasMany(Relas::class);
}
My model brokers like this:
public function relas()
{
return $this->hasMany(Relas::class);
}
And my Migration RELAS like this:
$table->id();
$table->unsignedBigInteger("vendas_id");
$table->unsignedBigInteger("corretores_id");
$table->string("tipo");
$table->timestamps();
$table->foreign("vendas_id")->references("id")->on("vendas")->cascadeOnDelete();
$table->foreign("corretores_id")->references("id")->on("corretores")->cascadeOnDelete();
Only I’m not able to make the relationship, because a sale has several brokers and various pickups, because of that I needed to make a separate relationship table, someone helps me?