@Override
public Connection getConnection() throws SQLException {
Connection connection = super.getConnection();
try (Statement sql = connection.createStatement()) {
sql.execute("SET app.current_tenant = '" + TenantContext.getTenant() + "'");
}
return connection;
}
The above code is an example in Java but I need a solution in PHP (Laravel).
I am trying to implement row-level security in Laravel and I have come across this article from AWS but not sure what's the ideal way to implement this. I already have a trait in Laravel that is used in every model class, shall I create another trait and add the set tenant here.
The current trait basically add where tenant_id = current_tenant but this approach implement the tenancy at database level as well.