You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use Laravel Nova for automatically generating admin screens and it supports Models that have BelongToMany relationships. However, an error is thrown when a BelongsToMany intermediate table doesn't contain an id column. This is because Postgres expects an id column to exist. (I've closed a ticket related to this here: #374)
The permissions table in Bouncer doesn't have an id column, and so when attempting to use Nova to manage Bouncer data, we get shown an error.
This is easily solved by adding an auto-incrementing id column to the Permissions table in Bouncer.
However, when we now try to call a Bouncer method such as Bouncer::allow($role)->to('do_something'); we get an error message SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "id" is ambiguous.
The solution is pretty simple once again, we just need to specify the table in the getAssociatedAbilityIds function in /src/Conductors/Concerns/AssociatesAbilities.php so that any references to id become abilities.id.
I appreciate this might be outside the scope of what is considered a bug as we are adding additional columns to the Bouncer permissions table, but if modifying the above function would not cause any problems, would it be possible to put this in place?
The text was updated successfully, but these errors were encountered:
We use Laravel Nova for automatically generating admin screens and it supports Models that have
BelongToMany
relationships. However, an error is thrown when aBelongsToMany
intermediate table doesn't contain anid
column. This is because Postgres expects anid
column to exist. (I've closed a ticket related to this here: #374)The
permissions
table in Bouncer doesn't have anid
column, and so when attempting to use Nova to manage Bouncer data, we get shown an error.This is easily solved by adding an auto-incrementing
id
column to the Permissions table in Bouncer.However, when we now try to call a Bouncer method such as
Bouncer::allow($role)->to('do_something');
we get an error messageSQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "id" is ambiguous
.The solution is pretty simple once again, we just need to specify the table in the
getAssociatedAbilityIds
function in/src/Conductors/Concerns/AssociatesAbilities.php
so that any references toid
becomeabilities.id
.I appreciate this might be outside the scope of what is considered a bug as we are adding additional columns to the Bouncer
permissions
table, but if modifying the above function would not cause any problems, would it be possible to put this in place?The text was updated successfully, but these errors were encountered: