Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyn table prefixes and $guarded don't work (Laravel 7.25+) #959

Open
FreekVR opened this issue Sep 8, 2020 · 0 comments
Open

Hyn table prefixes and $guarded don't work (Laravel 7.25+) #959

FreekVR opened this issue Sep 8, 2020 · 0 comments

Comments

@FreekVR
Copy link

FreekVR commented Sep 8, 2020

Description

Following the instructions for installing the spatie roles and permissions package no longer works with Laravel 7.25 due to framework changes in detecting fillable columns in a recent security patch.

To summarise:

  • Laravel now checks the database table associated with a model to detect fillable columns (when using $guarded instead of explicit $fillable)
  • The spatie Role model uses $guarded = ['id'] to make all other columns on the table implicitly fillable
  • The PrefixAllTableNames-trait for Hyn prefixes table names with the database/connection name
  • Laravel doesn't support detecting columns using "dot notation" for table names: Method getColumnListing doesn't work on postgresql using multiple schemas laravel/framework#34185
  • As a result, the Role model for this package, as well as other models with the same setup, do not work when using fillables. Eg.

Role::create(['name' => 'Foo']); yields an SQL error column 'name' cannot be NULL

I was able to get the fillables working by removing the PrefixAllTableNames-trait, but this leads to errors further down, because in for example subqueries the table name isn't prefixed with the correct connection.

Information

  • hyn/multi-tenant version: latest
  • laravel version:7.27.0
  • database driver and version: MySQL 5.7
  • webserver software and version: Nginx 1.17
  • php version: 7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant