Support the ongoing development of Laravel.io →
Database Eloquent Installation
Last updated 1 year ago.
0

How are your tables set up? Does your groups table have a column called role_id?

Last updated 8 years ago.
0

Hi Ftiersch , thanks for your reply, here are my migrations.

Groups Migration

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();
        });
    }

Roles Migration

public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('slug');
            $table->timestamps();
        });
    }
0

My bad, the problem was that I was inserting the role_id with the DB:: , with associate function works just fine.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.