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

Can't add BREAD to table with multiple indexes #5936

Open
parriondo opened this issue Dec 17, 2024 · 1 comment
Open

Can't add BREAD to table with multiple indexes #5936

parriondo opened this issue Dec 17, 2024 · 1 comment

Comments

@parriondo
Copy link

Laravel version

11.35.1

PHP version

8.3.12

Voyager version

1.8

Database

MySQL 8.0.3

Description

When adding a BREAD, it gives the following error:
Internal Server Error
ErrorException
Undefined array key 0
\vendor\tcg\voyager\src\Database\Schema\SchemaManager.php :77

The error occurs because the searched index is in position 5 of the index array. Thus, the function getColumnIndexes($table, $column) returns an array with a single element of index 4. Then, when $indexes[0]['type'] is evaluated, the exception is raised

Steps to reproduce

Add a BREAD for a table that has multiple indexes: 1 Primary key and 4 key (FK)

Expected behavior

Voayger should show the BREAD creation and configuration screen

Screenshots

Captura de pantalla 2024-12-17 080542

Additional context

No response

@parriondo
Copy link
Author

Possible solution: in \vendor\tcg\voyager\src\Database\Schema\SchemaManager::getColumnIndexes($table, $column), return array_values() of the collect()->toArray():
return array_values(collect($tableIndexes)->filter(function ($index) use ($column) {
return in_array($column, $index['columns']);
})->toArray());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant