浏览代码

csv

master
farhan 3 个月前
父节点
当前提交
d758f883ad
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8
    4
      app/Http/Controllers/MainController.php

+ 8
- 4
app/Http/Controllers/MainController.php 查看文件

@@ -75,9 +75,11 @@ class MainController extends Controller
75 75
     {
76 76
         $vips = RSVP::where('is_vip', true)->get();
77 77
 
78
-        $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
78
+        $csvData = "\xEF\xBB\xBF" . "No,Nama,Bilangan,No Tel\n";
79
+        $count = 1;
79 80
         foreach ($vips as $vip) {
80
-            $csvData .= "\t{$vip->name},{$vip->member},\t{$vip->phone}\n";
81
+            $csvData .= "{$count},\t{$vip->name},{$vip->member},\t{$vip->phone}\n";
82
+            $count++;
81 83
         }
82 84
 
83 85
         $fileName = "vip_data.csv";
@@ -93,9 +95,11 @@ class MainController extends Controller
93 95
     {
94 96
         $generals = RSVP::where('is_vip', false)->get();
95 97
 
96
-        $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
98
+        $csvData = "\xEF\xBB\xBF" . "No,Nama,Bilangan,No Tel\n";
99
+        $count = 1;
97 100
         foreach ($generals as $general) {
98
-            $csvData .= "\t{$general->name},{$general->member},\t{$general->phone}\n";
101
+            $csvData .= "{$count},\t{$general->name},{$general->member},\t{$general->phone}\n";
102
+            $count++;
99 103
         }
100 104
 
101 105
         $fileName = "general_data.csv";

正在加载...
取消
保存