How are your tables set up? Does your groups table have a column called role_id?
Hi Ftiersch , thanks for your reply, here are my migrations.
public function up()
{
Schema::create('grupos', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('slug');
$table->integer('role_id')->unsigned();
$table->foreign('role_id')->references('id')->on('roles');
$table->timestamps();
});
}
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('slug');
$table->timestamps();
});
}
My bad, the problem was that I was inserting the role_id with the DB:: , with associate function works just fine.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community