/**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $csv = file_get_contents('https://docs.google.com/spreadsheets/d/1a4wpAgCe1o3lY0KjY2K1bM-Sxr1IfOLqTXR_Wasp2hw/pub?output=csv');
     $csv_path = storage_path() . '/event_list.csv';
     File::put($csv_path, $csv);
     $csvObj = new \mnshankar\CSV\CSV();
     $arr = $csvObj->fromFile($csv_path)->toArray();
     $data = array();
     $curtype = "";
     $curdata = 0;
     foreach ($arr as $key => $row) {
         if ($row['type'] == "type") {
             if ($curdata != 0) {
                 $data[$curtype] = $curdata;
             }
             $curtype = $row['name'];
             $curdata = array('description' => $row['description'], 'events' => array());
         } else {
             if (trim($row['type']) == "event") {
                 array_push($curdata['events'], $row);
             }
         }
     }
     if ($curdata != 0) {
         $data[$curtype] = $curdata;
     }
     //print_r($data);
     return view('pages.home', array('data' => $data));
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->beforeRun();
     DB::table('Tag')->truncate();
     $csv = new \mnshankar\CSV\CSV();
     $tags = $csv->fromFile(dirname(__FILE__) . '/csv/Tag.csv')->toArray();
     foreach ($tags as $t) {
         \App\Models\Tag::create($t);
     }
     $this->afterRun();
 }