diff --git a/.prettierignore b/.prettierignore
index 26c8be6..eddc954 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -8,6 +8,7 @@ resources/views/emails
resources/views/mail
resources/views/vendor
resources/views/welcome.blade.php
+storage/framework/cache/laravel-excel
storage/framework/views
composer.lock
docker-compose.yml
diff --git a/app/Console/Commands/DatabaseStructExport.php b/app/Console/Commands/DatabaseStructExport.php
new file mode 100644
index 0000000..99f44fe
--- /dev/null
+++ b/app/Console/Commands/DatabaseStructExport.php
@@ -0,0 +1,42 @@
+info('Exporting database structure...');
+
+ try {
+ Excel::store(new \App\Exports\DatabaseStructExport(), 'database-struct.xlsx');
+ } catch (Throwable $th) {
+ $this->error('Failed to export database structure.');
+ }
+
+ $this->info('Database structure exported successfully.');
+ }
+}
diff --git a/app/Exports/DatabaseStructExport.php b/app/Exports/DatabaseStructExport.php
new file mode 100644
index 0000000..d8c9ce9
--- /dev/null
+++ b/app/Exports/DatabaseStructExport.php
@@ -0,0 +1,41 @@
+tables = array_map(function ($table) {
+ $key = 'Tables_in_' . Str::lower(DB::connection()->getDatabaseName());
+
+ // 获取表注释
+ $comment = DB::select('SHOW TABLE STATUS WHERE Name = ?', [$table->{$key}])[0]->Comment;
+
+ return [
+ 'name' => $table->{$key},
+ 'title' => $comment,
+ 'description' => $comment,
+ ];
+ }, DB::select('SHOW TABLES'));
+ }
+
+ public function sheets(): array
+ {
+ return array_merge([
+ new Sheets\TablesSheet($this->tables),
+ ], array_map(function ($table) {
+ return new Sheets\TableSheet($table);
+ }, $this->tables));
+ }
+}
diff --git a/app/Exports/Sheets/TableSheet.php b/app/Exports/Sheets/TableSheet.php
new file mode 100644
index 0000000..a6f78c3
--- /dev/null
+++ b/app/Exports/Sheets/TableSheet.php
@@ -0,0 +1,59 @@
+columns = DB::select('SHOW FULL COLUMNS FROM ' . data_get($this->table, 'name'));
+ }
+
+ public function title(): string
+ {
+ return data_get($this->table, 'name');
+ }
+
+ public function columnWidths(): array
+ {
+ return [
+ 'B' => 20,
+ ];
+ }
+
+ public function styles(Worksheet $sheet): void
+ {
+ $sheet->getStyle('B2:C4')->getBorders()->applyFromArray([
+ 'allBorders' => [
+ 'borderStyle' => Border::BORDER_THIN,
+ ],
+ ]);
+ $sheet->getStyle('B6:H' . (count($this->columns) + 6))->getBorders()->applyFromArray([
+ 'allBorders' => [
+ 'borderStyle' => Border::BORDER_THIN,
+ ],
+ ]);
+ }
+
+ public function view(): View
+ {
+ return view('exports.database_struct.table', [
+ 'table' => $this->table,
+ 'columns' => $this->columns,
+ ]);
+ }
+}
diff --git a/app/Exports/Sheets/TablesSheet.php b/app/Exports/Sheets/TablesSheet.php
new file mode 100644
index 0000000..8d46c5d
--- /dev/null
+++ b/app/Exports/Sheets/TablesSheet.php
@@ -0,0 +1,50 @@
+ 10,
+ ];
+ }
+
+ public function styles(Worksheet $sheet): void
+ {
+ $sheet->getStyle('B2')->getFont()->setBold(true)->setSize(18);
+ $sheet->getStyle('B3:D57')->getBorders()->applyFromArray([
+ 'allBorders' => [
+ 'borderStyle' => Border::BORDER_THIN,
+ ],
+ ]);
+ }
+
+ public function view(): View
+ {
+ return view('exports.database_struct.tables', [
+ 'tables' => $this->tables,
+ ]);
+ }
+}
diff --git a/resources/views/exports/database_struct/table.blade.php b/resources/views/exports/database_struct/table.blade.php
new file mode 100644
index 0000000..a60d422
--- /dev/null
+++ b/resources/views/exports/database_struct/table.blade.php
@@ -0,0 +1,52 @@
+
+
+
+
+ |
+ テーブル名称 |
+ 管理者と店舗の中間テーブル |
+
+
+ |
+ テーブル名 |
+
+ {{ data_get($table, 'name') }}
+ |
+
+
+ |
+ 概要 |
+
+ {{ data_get($table, 'description') }}
+ |
+
+
+
+
+
+
+ |
+ No. |
+ カラム名 |
+ データ型 |
+ 桁数 |
+ Not Null |
+ デフォルト |
+ 備考 |
+
+
+
+ @foreach ($columns as $key => $column)
+
+ |
+ {{ $key + 1 }} |
+ {{ $column->Field }} |
+ {{ $column->Type }} |
+ {{ $column->Type }} |
+ {{ $column->Null }} |
+ {{ $column->Default }} |
+ {{ $column->Comment }} |
+
+ @endforeach
+
+
diff --git a/resources/views/exports/database_struct/tables.blade.php b/resources/views/exports/database_struct/tables.blade.php
new file mode 100644
index 0000000..611e091
--- /dev/null
+++ b/resources/views/exports/database_struct/tables.blade.php
@@ -0,0 +1,25 @@
+
+
+
+
+ |
+ テーブル一覧 |
+
+
+ |
+ No. |
+ テーブル名 |
+ 備考 |
+
+ @foreach ($tables as $key => $table)
+
+ |
+ {{ $key + 1 }} |
+ {{ data_get($table, 'name') }} |
+
+ {{ data_get($table, 'title') }}
+ |
+
+ @endforeach
+
+