/** * Responds to requests to POST /lorem */ public function postGenerate(Request $request) { // Validate the request data // num_users - how many users should be created // tb_word_count - how many words in password $this->validate($request, ['num_users' => 'required|integer|min:1|max:99', 'tb_word_count' => 'integer|min:1|max:9']); $num_users = $request->input('num_users'); $lang = $request->input('lang'); $address1 = $request->input('address1'); $profile = $request->input('profile'); $tb_word_count = $request->input('tb_word_count'); $cb_number = $request->input('cb_number'); $cb_symbol = $request->input('cb_symbol'); $pwd_case = $request->input('pwd_case'); //The section below declares the arrays needed to hold random user data //and then populates those arrays. //instantiate new PwdGenerator object $a = new \App\PwdGenerator($tb_word_count, $pwd_case, $cb_number, $cb_symbol); $pwd_array = []; $faker = \Faker\Factory::create($lang); $name_array = []; $address_array = []; $profile_array = []; for ($i = 0; $i < $num_users; $i++) { // populate array with random names $name_array[$i] = $faker->name; //populate array with random address info $address_array[$i] = $faker->address; //populate array with random profile text $profile_array[$i] = $faker->text; //populate array with random passwords $pwd_array[$i] = $a->generatePwd(); } return view('random.generate')->with('num_users', $num_users)->with('lang', $lang)->with('address1', $address1)->with('profile', $profile)->with('tb_word_count', $tb_word_count)->with('cb_number', $cb_number)->with('cb_symbol', $cb_symbol)->with('pwd_case', $pwd_case)->with('name_array', $name_array)->with('address_array', $address_array)->with('profile_array', $profile_array)->with('pwd_array', $pwd_array); }
/** * Responds to requests to POST /lorem */ public function postGenerate(Request $request) { // Validate the request data // num_users - how many users should be created // tb_word_count - how many words in password $this->validate($request, ['num_users' => 'required|integer|min:1|max:99', 'tb_word_count' => 'integer|min:1|max:9']); $num_users = $request->input('num_users'); $lang = $request->input('lang'); $address = $request->input('address'); $profile = $request->input('profile'); $tb_word_count = $request->input('tb_word_count'); $cb_number = $request->input('cb_number'); $cb_symbol = $request->input('cb_symbol'); $pwd_case = $request->input('pwd_case'); //call functions here and populate arrays. Be sure to pass arrays to //view below. On view, can use syntax: echo implode('<p>', $x_array); $a = new \App\PwdGenerator($tb_word_count, $pwd_case, $cb_number, $cb_symbol); $pwd_array = []; for ($i = 0; $i < $num_users; $i++) { $pwd_array[$i] = $a->PrintPwd(); } return view('random.generate')->with('num_users', $num_users)->with('lang', $lang)->with('address', $address)->with('profile', $profile)->with('tb_word_count', $tb_word_count)->with('cb_number', $cb_number)->with('cb_symbol', $cb_symbol)->with('pwd_case', $pwd_case)->with($pwd_array); }