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)); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $input = $request->all(); /* * Creates Kiwanis Family Club attendees. */ if (array_key_exists('kiwanis_club_name', $input)) { foreach ($input['kiwanis_club_name'] as $index => $kiwanis_club) { $kiwanisAttendeeAttributes = ['cerf_id' => session()->get('cerf_id'), 'name' => $kiwanis_club, 'members_attended' => $input['num_members'][$index]]; KiwanisAttendee::create($kiwanisAttendeeAttributes); } } return redirect()->action('CerfsController@overview'); }