コード例 #1
0
 public function run()
 {
     $volunteers = \teambernieny\VDBVolunteer::all();
     //Top ten data conversion for now
     for ($x = 0; $x < sizeof($volunteers); $x++) {
         $volunteer = $volunteers[$x];
         //clean out the 999s
         $volunteer = $this->validate($volunteer);
         //add neighborhood if doesn't exist
         $neighborhoods = \teambernieny\Neighborhood::where('Name', '=', $volunteer->Neighborhood)->get();
         if (sizeof($neighborhoods) == 0 && $volunteer->Neighborhood != "") {
             DB::table('neighborhoods')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'Name' => $volunteer->Neighborhood, 'Borough' => $volunteer->City]);
             $neighborhood_id = \teambernieny\Neighborhood::max('id');
         } else {
             if ($volunteer->Neighborhood == "") {
                 $neighborhood_id = "1";
             } else {
                 $neighborhood_id = $neighborhoods[0]->id;
             }
         }
         // add volunteer
         DB::table('volunteers')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'FirstName' => $volunteer->FirstName, 'LastName' => $volunteer->LastName, 'Email' => $volunteer->EMail1, 'Phone' => $volunteer->Phone1, 'neighborhood_id' => $neighborhood_id, 'Zip' => $volunteer->Zip, 'Street' => $volunteer->Street, 'City' => $volunteer->City, 'State' => $volunteer->State, 'user_id' => "1", 'BadPhone' => $volunteer->Phone1Broken, 'BadEmail' => $volunteer->Email1Broken, 'DoNotContact' => $volunteer->DoNotContact]);
         $volunteerid = \teambernieny\Volunteer::max('id');
         DB::table('event_volunteers')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'event_id' => '1', 'volunteer_id' => $volunteerid, 'Relationship' => 'Attendee']);
         $eventvolunteers_id = \teambernieny\EventVolunteers::max('id');
         if ($volunteer->AttendEvent == "1") {
             DB::table('commitments')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'event_volunteers_id' => $eventvolunteers_id, 'Type' => "Attend"]);
         }
         if ($volunteer->HostEvent == "1") {
             DB::table('commitments')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'event_volunteers_id' => $eventvolunteers_id, 'Type' => "Host"]);
         }
     }
 }
コード例 #2
0
 private function checkNeighborhood(Request $request)
 {
     $neighborhoods = \teambernieny\Neighborhood::select('id')->where('Name', '=', $request->Neighborhood)->get();
     if (sizeof($neighborhoods) > 0) {
         $neighborhood = $neighborhoods->first();
         $neighborhood_id = $neighborhood->id;
     } else {
         $neighborhood = new \teambernieny\Neighborhood();
         $neighborhood->Name = $request->Neighborhood;
         $neighborhood->Borough = $request->City;
         $neighborhood->save();
         $neighborhood_id = $neighborhood->id;
     }
     return $neighborhood_id;
 }
コード例 #3
0
 public function getSearchZip(Request $request)
 {
     //get the zips for the columns
     $zips = \teambernieny\Volunteer::select('Zip')->distinct('Zip')->orderby('Zip')->get();
     $collength = sizeof($zips) / 12;
     for ($y = 0; $y < 12; $y++) {
         for ($x = 0; $x < $collength; $x++) {
             $zipcol[$x] = $zips[$x + $collength * $y];
         }
         $zipcols[$y] = $zipcol;
     }
     $neighborhoods = \teambernieny\Neighborhood::distinct('Name')->orderby('Borough')->get();
     $bronx = $neighborhoods->whereLoose('Borough', 'Bronx')->sortBy('Name');
     $brooklyn = $neighborhoods->whereLoose('Borough', 'Brooklyn')->sortBy('Name');
     $manhattan = $neighborhoods->whereLoose('Borough', 'Manhattan')->sortBy('Name');
     $queens = $neighborhoods->whereLoose('Borough', 'Queens')->sortBy('Name');
     $statenisland = $neighborhoods->whereLoose('Borough', 'Staten Island')->sortBy('Name');
     $other = \teambernieny\Neighborhood::distinct('Name')->whereNotIn('Borough', ['Bronx', 'Brooklyn', 'Manhattan', 'Queens', 'Staten Island'])->orderby('Name')->get();
     return view('volunteer.search.zip')->with(['zipcols' => $zipcols, 'bronx' => $bronx, 'brooklyn' => $brooklyn, 'manhattan' => $manhattan, 'queens' => $queens, 'statenisland' => $statenisland, 'other' => $other]);
 }
コード例 #4
0
 private function checkNeighborhood($name, $city)
 {
     $neighborhoods = \teambernieny\Neighborhood::select('id')->where('Name', '=', $name)->get();
     if (sizeof($neighborhoods) > 0) {
         $neighborhood = $neighborhoods->first();
     } else {
         $neighborhood = new \teambernieny\Neighborhood();
         $neighborhood->Name = $name;
         $neighborhood->Borough = $city;
         $neighborhood->save();
     }
     return $neighborhood->id;
 }
コード例 #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $file = fopen("/uploads/20160113.csv", "r");
     $line = fgets($file);
     ## Get the header line = Event(0),Date(1),FirstName(2),LastName(3),Gender(4),Phone(5),Zip(6),Neighborhood(7),Email(8),Street(9),City(10),State(11),HostEvent(12),AttendEvent(13),Comment(14)
     while (($line = fgets($handle)) !== false) {
         $data = explode(",", $line);
         if ($data[0] != "") {
             //check for event
             $events = \teambernieny\Event::where('Name', '=', $data[0])->get();
             if (sizeof($events) > 0) {
                 $event = $events[0];
             } else {
                 //add if doesn't exist
                 $event = new \teambernieny\Event();
                 $event->Name = $data[0];
                 $event->neighborhood_id = "1";
                 $event->Date = "2016-01-13";
                 $event->save();
             }
         } else {
             // add to migration if no event indicated
             $event = \teambernieny\Event::find('1');
         }
         if ($data[8] != "") {
             // if there is an email
             $volunteers = \teambernieny\Volunteer::where('Email', '=', $data[8])->get();
         } elseif ($data[5] != "") {
             $volunteers = \teambernieny\Volunteer::where('Phone', '=', $data[5])->get();
         } else {
             continue;
         }
         if (sizeof($volunteers) == 0) {
             $volunteer = new \teambernieny\Volunteer();
             $neighborhoods = \teambernieny\Neighborhood::select('id')->where('Name', '=', $data[7])->get();
             if (sizeof($neighborhoods) > 0) {
                 $neighborhood = $neighborhoods->first();
             } else {
                 $neighborhood = new \teambernieny\Neighborhood();
                 $neighborhood->Name = $data[7];
                 $neighborhood->Borough = $data[10];
                 $neighborhood->save();
             }
             $volunteer->FirstName = $data[2];
             $volunteer->LastName = $data[3];
             $volunteer->Phone = $data[5];
             $volunteer->Zip = $data[6];
             $volunteer->neighborhood_id = $neighborhood->id;
             $volunteer->Email = $data[8];
             $volunteer->Street = $data[9];
             $volunteer->City = $data[10];
             $volunteer->State = $data[11];
         } else {
             $volunteer = $volunteers[0];
         }
         //Add attendance
         $attendance = new \teambernieny\EventVolunteers();
         $attendance->event_id = $event->id;
         $attendance->volunteer_id = $volunteer->id;
         $attendance->Relationship = "Attendee";
         $attendance->save();
         if ($data[12] == "1") {
             $newcommitment = new \teambernieny\Commitment();
             $newcommitment->event_volunteers_id = $attendance->id;
             $newcommitment->Type = "Host";
             $newcommitment->save();
         }
         if ($data[13] == "1") {
             $newcommitment = new \teambernieny\Commitment();
             $newcommitment->event_volunteers_id = $attendance->id;
             $newcommitment->Type = "Attend";
             $newcommitment->save();
         }
     }
     fclose($file);
 }