public function run()
 {
     DB::table('kiwanis_attendees')->delete();
     $faker = Faker::create();
     $cerf_ids = Cerf::all()->lists('id')->toArray();
     for ($counter = 0; $counter < 30; $counter++) {
         $rand_cerf_id = $cerf_ids[array_rand($cerf_ids)];
         KiwanisAttendee::create(array('cerf_id' => $rand_cerf_id, 'name' => $faker->city . ' Kiwanis Club', 'members_attended' => $faker->randomDigit));
     }
 }
 public function run()
 {
     $faker = Faker::create();
     DB::table('cerfs')->delete();
     // Gets array of event IDs.
     $event_ids = Event::all()->lists('id')->toArray();
     shuffle($event_ids);
     $user_ids = User::all()->lists('id')->toArray();
     shuffle($user_ids);
     // TODO Events have many CERFs, so make sure to update seeder accordingly.
     // Each CERF should only have one event. Some events do not have an associated CERF.
     for ($counter = 0; $counter < 10; $counter++) {
         $event_id = $event_ids[$counter];
         $user_id = $user_ids[$counter];
         Cerf::create(array('event_id' => $event_id, 'reporter_id' => $user_id, 'amount_raised' => $faker->randomFloat(2, 0, 1000), 'amount_spent' => $faker->randomFloat(2, 0, 1000), 'net_profit' => $faker->randomFloat(2, 0, 1000), 'funds_purpose' => $faker->text, 'summary' => $faker->text, 'strengths' => $faker->text, 'weaknesses' => $faker->text, 'reflection' => $faker->text, 'approved' => false));
     }
 }
 public function run()
 {
     $faker = Faker::create();
     DB::table('activity_log')->delete();
     // Gets an array with event IDs and an array with user IDs.
     $cerf_ids = Cerf::all()->lists('id')->toArray();
     $user_ids = User::all()->lists('id')->toArray();
     for ($counter = 0; $counter < 30; $counter++) {
         // Chooses random keys in both arrays.
         $rand_cerf_id = $cerf_ids[array_rand($cerf_ids)];
         $rand_user_id = $user_ids[array_rand($user_ids)];
         // No two activity records should have the same user_id and cerf_id combination.
         if (Activity::where('user_id', '=', $rand_user_id)->where('cerf_id', '=', $rand_cerf_id)->exists()) {
             continue;
         }
         Activity::create(array('user_id' => $rand_user_id, 'cerf_id' => $rand_cerf_id, 'service_hours' => $faker->randomDigit, 'planning_hours' => $faker->randomDigit, 'traveling_hours' => $faker->randomDigit, 'admin_hours' => $faker->randomDigit, 'social_hours' => $faker->randomDigit, 'mileage' => $faker->randomDigit, 'notes' => $faker->paragraph));
     }
 }
 /**
  * Approves a CERF by deleting all other pending CERFs for the same event.
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function approve($id)
 {
     $cerf = Cerf::find($id);
     $cerf->update(['approved' => true]);
     $otherCerfs = Cerf::where('event_id', $cerf->event_id)->where('approved', false)->get();
     foreach ($otherCerfs as $cerf) {
         // See comments in CerfsController@destroy.
         DB::statement('delete from cerfs where id=' . $cerf->id);
         DB::statement('delete from events_assigned_tags where cerf_id=' . $cerf->id);
     }
     return redirect()->action('CerfsController@overview');
 }