diff --git a/app/Http/Controllers/Admin/StationController.php b/app/Http/Controllers/Admin/StationController.php index 0866281..0aea0ae 100644 --- a/app/Http/Controllers/Admin/StationController.php +++ b/app/Http/Controllers/Admin/StationController.php @@ -196,18 +196,34 @@ class StationController extends Controller } /** - * CSVエクスポート + * CSVエクスポート(日本語ヘッダー付き) */ public function export() { - return response()->streamDownload(function () { - // Excel用のUTF-8 BOM - echo "\xEF\xBB\xBF"; - echo "station_id,station_neighbor_station,station_name_ruby,station_route_name,park_id,operator_id\n"; + // ファイル名 + $filename = '近傍駅マスタ_' . now()->format('YmdHis') . '.csv'; - foreach (Station::all() as $station) { - echo "{$station->station_id},{$station->station_neighbor_station},{$station->station_name_ruby},{$station->station_route_name},{$station->park_id},{$station->operator_id}\n"; + return response()->streamDownload(function () { + // Excel用 UTF-8 BOM + echo "\xEF\xBB\xBF"; + + // 日本語ヘッダー行 + echo "近傍駅ID,駐車場ID,近傍駅,近傍駅ふりがな,路線名,近傍駅座標(緯度),近傍駅座標(経度)\n"; + + // データ行 + foreach (\App\Models\Station::all() as $station) { + echo implode(',', [ + $station->station_id, + $station->park_id, + $station->station_neighbor_station, + $station->station_name_ruby, + $station->station_route_name, + $station->station_latitude, + $station->station_longitude, + // $station->operator_id, + ]) . "\n"; } - }, 'stations.csv'); + }, $filename); } + }