Browse Source

csv

master
farhan 3 months ago
parent
commit
d758f883ad
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      app/Http/Controllers/MainController.php

+ 8
- 4
app/Http/Controllers/MainController.php View File

75
     {
75
     {
76
         $vips = RSVP::where('is_vip', true)->get();
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
         foreach ($vips as $vip) {
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
         $fileName = "vip_data.csv";
85
         $fileName = "vip_data.csv";
93
     {
95
     {
94
         $generals = RSVP::where('is_vip', false)->get();
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
         foreach ($generals as $general) {
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
         $fileName = "general_data.csv";
105
         $fileName = "general_data.csv";

Loading…
Cancel
Save