Skip to content

Commit 467bd41

Browse files
committed
fix: BadMethodCallException Method Illuminate\Database\MySqlConnection::isDoctrineAvailable and remove DBAL
1 parent 07af1a2 commit 467bd41

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"php": ">=8.2",
2525
"symfony/dom-crawler": "~7.3",
2626
"laravel/framework": "^12.0",
27-
"doctrine/dbal": "^4.3",
2827
"intervention/image": "^2.7"
2928
},
3029
"require-dev": {

src/Console/ResourceGenerator.php

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ public function generateForm()
8989
$output = '';
9090

9191
foreach ($this->getTableColumns() as $column) {
92-
$name = $column->getName();
92+
$name = $column['name'];
9393
if (in_array($name, $reservedColumns)) {
9494
continue;
9595
}
96-
$type = $column->getType()->getName();
97-
$default = $column->getDefault();
96+
97+
['type'=> $type, 'default' => $default] = $column;
9898

9999
$defaultValue = '';
100100

@@ -172,7 +172,7 @@ public function generateShow()
172172
$output = '';
173173

174174
foreach ($this->getTableColumns() as $column) {
175-
$name = $column->getName();
175+
$name = $column['name'];
176176

177177
// set column label
178178
$label = $this->formatLabel($name);
@@ -190,7 +190,7 @@ public function generateGrid()
190190
$output = '';
191191

192192
foreach ($this->getTableColumns() as $column) {
193-
$name = $column->getName();
193+
$name = $column['name'];
194194
$label = $this->formatLabel($name);
195195

196196
$output .= sprintf($this->formats['grid_column'], $name, $label);
@@ -215,35 +215,15 @@ protected function getReservedColumns()
215215
*
216216
* @throws \Exception
217217
*
218-
* @return \Doctrine\DBAL\Schema\Column[]
218+
* @return list<array{name: string, type: string, type_name: string, nullable: bool, default: mixed, auto_increment: bool, comment: string|null, generation: array{type: string, expression: string|null}|null}>
219219
*/
220220
protected function getTableColumns()
221221
{
222-
if (!$this->model->getConnection()->isDoctrineAvailable()) {
223-
throw new \Exception(
224-
'You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. '
225-
);
226-
}
227-
228-
$table = $this->model->getConnection()->getTablePrefix() . $this->model->getTable();
229-
/** @var \Doctrine\DBAL\Schema\MySqlSchemaManager $schema */
230-
$schema = $this->model->getConnection()->getDoctrineSchemaManager($table);
231-
232-
// custom mapping the types that doctrine/dbal does not support
233-
$databasePlatform = $schema->getDatabasePlatform();
222+
$schema = $this->model->getConnection()->getSchemaBuilder();
234223

235-
foreach ($this->doctrineTypeMapping as $doctrineType => $dbTypes) {
236-
foreach ($dbTypes as $dbType) {
237-
$databasePlatform->registerDoctrineTypeMapping($dbType, $doctrineType);
238-
}
239-
}
240-
241-
$database = null;
242-
if (strpos($table, '.')) {
243-
list($database, $table) = explode('.', $table);
244-
}
224+
$table = $this->model->getTable();
245225

246-
return $schema->listTableColumns($table, $database);
226+
return $schema->getColumns($table);
247227
}
248228

249229
/**

0 commit comments

Comments
 (0)