From c5de7fefbca78e202bbd2aa57c9390226513eb3a Mon Sep 17 00:00:00 2001 From: Evgenii Eliseev Date: Thu, 29 May 2025 14:45:06 +0300 Subject: [PATCH 1/4] fix doctrine not more integrated in Laravel 11 #5864 --- src/Console/ResourceGenerator.php | 36 +++++++------------------------ 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/Console/ResourceGenerator.php b/src/Console/ResourceGenerator.php index 16c9ee5fd8..3a8716054c 100644 --- a/src/Console/ResourceGenerator.php +++ b/src/Console/ResourceGenerator.php @@ -3,6 +3,7 @@ namespace Encore\Admin\Console; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Schema; class ResourceGenerator { @@ -83,12 +84,12 @@ public function generateForm() $output = ''; foreach ($this->getTableColumns() as $column) { - $name = $column->getName(); + $name = $column['name']; if (in_array($name, $reservedColumns)) { continue; } - $type = $column->getType()->getName(); - $default = $column->getDefault(); + $type = $column['type_name']; + $default = $column['default']; $defaultValue = ''; @@ -166,7 +167,7 @@ public function generateShow() $output = ''; foreach ($this->getTableColumns() as $column) { - $name = $column->getName(); + $name = $column['name']; // set column label $label = $this->formatLabel($name); @@ -184,7 +185,7 @@ public function generateGrid() $output = ''; foreach ($this->getTableColumns() as $column) { - $name = $column->getName(); + $name = $column['name']; $label = $this->formatLabel($name); $output .= sprintf($this->formats['grid_column'], $name, $label); @@ -213,31 +214,10 @@ protected function getReservedColumns() */ protected function getTableColumns() { - if (!$this->model->getConnection()->isDoctrineAvailable()) { - throw new \Exception( - 'You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. ' - ); - } $table = $this->model->getConnection()->getTablePrefix().$this->model->getTable(); - /** @var \Doctrine\DBAL\Schema\MySqlSchemaManager $schema */ - $schema = $this->model->getConnection()->getDoctrineSchemaManager($table); - - // custom mapping the types that doctrine/dbal does not support - $databasePlatform = $schema->getDatabasePlatform(); - - foreach ($this->doctrineTypeMapping as $doctrineType => $dbTypes) { - foreach ($dbTypes as $dbType) { - $databasePlatform->registerDoctrineTypeMapping($dbType, $doctrineType); - } - } - - $database = null; - if (strpos($table, '.')) { - list($database, $table) = explode('.', $table); - } - return $schema->listTableColumns($table, $database); + return Schema::getColumns($table); } /** @@ -251,4 +231,4 @@ protected function formatLabel($value) { return ucfirst(str_replace(['-', '_'], ' ', $value)); } -} +} \ No newline at end of file From 635ca77e76fd016b64385ac1207a4a1d171b5c3a Mon Sep 17 00:00:00 2001 From: Evgenii Eliseev Date: Thu, 29 May 2025 14:47:14 +0300 Subject: [PATCH 2/4] fix doctrine not more integrated in Laravel 11 #5864 --- src/Console/ResourceGenerator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/ResourceGenerator.php b/src/Console/ResourceGenerator.php index 3a8716054c..d6729e9b7c 100644 --- a/src/Console/ResourceGenerator.php +++ b/src/Console/ResourceGenerator.php @@ -214,7 +214,6 @@ protected function getReservedColumns() */ protected function getTableColumns() { - $table = $this->model->getConnection()->getTablePrefix().$this->model->getTable(); return Schema::getColumns($table); From 84d8baecd813cd37059aa913f814ff39a6a0ace1 Mon Sep 17 00:00:00 2001 From: Evgenii Eliseev Date: Thu, 29 May 2025 14:47:53 +0300 Subject: [PATCH 3/4] fix doctrine not more integrated in Laravel 11 #5864 --- src/Console/ResourceGenerator.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Console/ResourceGenerator.php b/src/Console/ResourceGenerator.php index d6729e9b7c..8249d8c6bf 100644 --- a/src/Console/ResourceGenerator.php +++ b/src/Console/ResourceGenerator.php @@ -16,8 +16,8 @@ class ResourceGenerator * @var array */ protected $formats = [ - 'form_field' => "\$form->%s('%s', __('%s'))", - 'show_field' => "\$show->field('%s', __('%s'))", + 'form_field' => "\$form->%s('%s', __('%s'))", + 'show_field' => "\$show->field('%s', __('%s'))", 'grid_column' => "\$grid->column('%s', __('%s'))", ]; @@ -36,14 +36,14 @@ class ResourceGenerator * @var array */ protected $fieldTypeMapping = [ - 'ip' => 'ip', - 'email' => 'email|mail', + 'ip' => 'ip', + 'email' => 'email|mail', 'password' => 'password|pwd', - 'url' => 'url|link|src|href', - 'mobile' => 'mobile|phone', - 'color' => 'color|rgb', - 'image' => 'image|img|avatar|pic|picture|cover', - 'file' => 'file|attachment', + 'url' => 'url|link|src|href', + 'mobile' => 'mobile|phone', + 'color' => 'color|rgb', + 'image' => 'image|img|avatar|pic|picture|cover', + 'file' => 'file|attachment', ]; /** @@ -208,13 +208,13 @@ protected function getReservedColumns() /** * Get columns of a giving model. * + * @return \Doctrine\DBAL\Schema\Column[] * @throws \Exception * - * @return \Doctrine\DBAL\Schema\Column[] */ protected function getTableColumns() { - $table = $this->model->getConnection()->getTablePrefix().$this->model->getTable(); + $table = $this->model->getConnection()->getTablePrefix() . $this->model->getTable(); return Schema::getColumns($table); } From dd297af595dd7c8065a2197c8e9a12ed375abf52 Mon Sep 17 00:00:00 2001 From: Evgenii Eliseev Date: Thu, 29 May 2025 14:50:30 +0300 Subject: [PATCH 4/4] fix doctrine not more integrated in Laravel 11 #5864 --- src/Console/ResourceGenerator.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Console/ResourceGenerator.php b/src/Console/ResourceGenerator.php index 8249d8c6bf..0b89b8f88a 100644 --- a/src/Console/ResourceGenerator.php +++ b/src/Console/ResourceGenerator.php @@ -16,8 +16,8 @@ class ResourceGenerator * @var array */ protected $formats = [ - 'form_field' => "\$form->%s('%s', __('%s'))", - 'show_field' => "\$show->field('%s', __('%s'))", + 'form_field' => "\$form->%s('%s', __('%s'))", + 'show_field' => "\$show->field('%s', __('%s'))", 'grid_column' => "\$grid->column('%s', __('%s'))", ]; @@ -36,14 +36,14 @@ class ResourceGenerator * @var array */ protected $fieldTypeMapping = [ - 'ip' => 'ip', - 'email' => 'email|mail', + 'ip' => 'ip', + 'email' => 'email|mail', 'password' => 'password|pwd', - 'url' => 'url|link|src|href', - 'mobile' => 'mobile|phone', - 'color' => 'color|rgb', - 'image' => 'image|img|avatar|pic|picture|cover', - 'file' => 'file|attachment', + 'url' => 'url|link|src|href', + 'mobile' => 'mobile|phone', + 'color' => 'color|rgb', + 'image' => 'image|img|avatar|pic|picture|cover', + 'file' => 'file|attachment', ]; /** @@ -208,13 +208,13 @@ protected function getReservedColumns() /** * Get columns of a giving model. * - * @return \Doctrine\DBAL\Schema\Column[] * @throws \Exception * + * @return \Doctrine\DBAL\Schema\Column[] */ protected function getTableColumns() { - $table = $this->model->getConnection()->getTablePrefix() . $this->model->getTable(); + $table = $this->model->getConnection()->getTablePrefix().$this->model->getTable(); return Schema::getColumns($table); } @@ -230,4 +230,4 @@ protected function formatLabel($value) { return ucfirst(str_replace(['-', '_'], ' ', $value)); } -} \ No newline at end of file +}