Yes, you can specify the foreign key column name in the belongsToMany method when defining the relationship between the model and the permissions. Here's an example assuming the model is named MyModel and the primary key column is named my_model_id:
use Spatie\Permission\Models\Permission;
class MyModel extends Model
{
public function permissions()
{
return $this->belongsToMany(Permission::class, 'my_model_permissions', 'my_model_id', 'permission_id');
}
}
In this example, the third argument 'my_model_id' specifies the name of the foreign key column in the pivot table. Replace 'my_model_permissions' with the name of your pivot table and 'permission_id' with the name of the foreign key column for the permissions table if they are different.