如何定义laravel 5.3 eloquent模型中的关系?

I have tables in my database schema as follows,

enter image description here

Is it pivot table?

How can I define relationship in eloquent model?

    class Role extends Model {

    public $timestamps = false;

    public function permissions() {
        return $this->hasMany('App\Models\RolePermission', 'permissions_id');
    }

}

Is this correct way to define relationship? Please help me to understand.

and

    class RolePermission extends Model {

    public $timestamps = false;

    public function role() {
        return $this->belongsTo('App\Models\Role', 'roles_id');
    }

}

The problem is that you need to name your table permission_role to follow the design pragma.

Role Schema

Schema::create('roles', function(Blueprint $table){
    $table->increments('id');
    $table->string('name');

    $table->timestamps();
});

Permission schema

Schema::create('permissions', function(Blueprint $table){
    $table->increments('id');
    $table->string('name');

    $table->timestamps();
});

Then you just need the permission_role table:

Permission_Role schema

Schema::create('permission_role', function(Blueprint $table){
    $table->increments('id');

    $table->integer('permission_id')->unsigned();
        $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');

    $table->integer('role_id')->unsigned();
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
});

Then you just set up your models like this:

class Role {
    public function permissions() {
        return $this->hasMany(App\Permission::class);
    }
}

Then of course your permission class

class Permission {
    public function role() {
        return $this->belongsToMany(App\Role::class);
    }
}

its a many to many relationship bond together by a pivot table Permission_Role. there for each table belongsToMany not hasOne or hasMany

class Role {
    public function permissions() {
        return $this->belongsToMany(App\Permission::class);
    }
}

class Permission {
    public function role() {
        return $this->belongsToMany(App\Role::class);
    }
}