Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

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

Open
parriondo opened this issue Dec 17, 2024 · 3 comments
Open

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

parriondo opened this issue Dec 17, 2024 · 3 comments

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());

@stjnvc
Copy link

stjnvc commented Feb 5, 2025

Same. Someone has solution to this?

@stjnvc
Copy link

stjnvc commented Feb 7, 2025

Jesus Christe

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

No branches or pull requests

2 participants