public function run() { DB::table('UserData')->delete(); UserData::create(['id' => '1', 'name' => 'Mickey Mouse', 'isAdmin' => true]); UserData::create(['id' => '2', 'name' => 'Donald Duck', 'team_style' => 'social', 'taken_programming_class' => '306', 'preferred_language' => 'c']); UserData::create(['id' => '3', 'name' => 'Jane Jetson', 'team_style' => 'social', 'taken_programming_class' => '306', 'preferred_language' => 'java']); UserData::create(['id' => '4', 'name' => 'Frodo Baggins', 'team_style' => 'social', 'taken_programming_class' => '306', 'preferred_language' => 'python']); UserData::create(['id' => '5', 'name' => 'Bilbo Baggins', 'team_style' => 'social', 'taken_programming_class' => '261', 'preferred_language' => 'c']); UserData::create(['id' => '6', 'name' => 'Winnie Poohbear', 'team_style' => 'social', 'taken_programming_class' => '261', 'preferred_language' => 'java']); UserData::create(['id' => '7', 'name' => 'Daffy Duck', 'team_style' => 'social', 'taken_programming_class' => '261', 'preferred_language' => 'python']); UserData::create(['id' => '8', 'name' => 'Wile Coyote', 'team_style' => 'social', 'taken_programming_class' => '261', 'preferred_language' => 'c']); UserData::create(['id' => '9', 'name' => 'Road Runner', 'team_style' => 'social', 'taken_programming_class' => '262', 'preferred_language' => 'java']); UserData::create(['id' => '10', 'name' => 'Marge Simpson', 'team_style' => 'social', 'taken_programming_class' => '262', 'preferred_language' => 'python']); UserData::create(['id' => '11', 'name' => 'Charlie Brown', 'team_style' => 'social', 'taken_programming_class' => '262', 'preferred_language' => 'c']); UserData::create(['id' => '12', 'name' => 'Lucy VanPelt', 'team_style' => 'social', 'taken_programming_class' => '262', 'preferred_language' => 'java']); UserData::create(['id' => '13', 'name' => 'Bugs Bunny', 'team_style' => 'social', 'taken_programming_class' => '262', 'preferred_language' => 'python']); UserData::create(['id' => '14', 'name' => 'Betty Boop', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'c']); UserData::create(['id' => '15', 'name' => 'Lois Griffin', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'java']); UserData::create(['id' => '16', 'name' => 'Wilma Flintstone', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'python']); UserData::create(['id' => '17', 'name' => 'Fred Flintstone', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'c']); UserData::create(['id' => '18', 'name' => 'Peppa Pig', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'java']); UserData::create(['id' => '19', 'name' => 'Turanga Leela', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'python']); UserData::create(['id' => '20', 'name' => 'Sylvester Cat', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'c']); UserData::create(['id' => '21', 'name' => 'Felix Cat', 'team_style' => 'competitive', 'taken_programming_class' => '306', 'preferred_language' => 'java']); UserData::create(['id' => '22', 'name' => 'Top Cat', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'python']); UserData::create(['id' => '23', 'name' => 'Scooby Doo', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'c']); UserData::create(['id' => '24', 'name' => 'Porky Pig', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'java']); UserData::create(['id' => '25', 'name' => 'Garfield Cat', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'python']); UserData::create(['id' => '26', 'name' => 'Peter Pan', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'c']); UserData::create(['id' => '27', 'name' => 'Foghorn Leghorn', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'java']); UserData::create(['id' => '28', 'name' => 'Manning Peyton', 'team_style' => 'competitive', 'taken_programming_class' => '261', 'preferred_language' => 'python']); UserData::create(['id' => '29', 'name' => 'Green Virgil', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'c']); UserData::create(['id' => '30', 'name' => 'Thomas Julias', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'java']); UserData::create(['id' => '31', 'name' => 'Sanders Emmanuel', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'python']); UserData::create(['id' => '32', 'name' => 'Tamme Jason', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'c']); UserData::create(['id' => '33', 'name' => 'Knighton Terrance', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'java']); UserData::create(['id' => '34', 'name' => 'Colquitt Britton', 'team_style' => 'competitive', 'taken_programming_class' => '262', 'preferred_language' => 'python']); UserData::create(['id' => '35', 'name' => 'Roby Bradley', 'team_style' => 'dontcare', 'taken_programming_class' => '262', 'preferred_language' => 'c']); UserData::create(['id' => '36', 'name' => 'Ward T.J.', 'team_style' => 'dontcare', 'taken_programming_class' => '262', 'preferred_language' => 'java']); UserData::create(['id' => '37', 'name' => 'Ware DeMarcus', 'team_style' => 'dontcare', 'taken_programming_class' => '262', 'preferred_language' => 'python']); UserData::create(['id' => '38', 'name' => 'Webster, Kayvon', 'team_style' => 'dontcare', 'taken_programming_class' => '262', 'preferred_language' => 'c']); }
public function updater() { $classesRequest = array_only(Request::all(), array('262', '261', '306', '406')); $requests = array_except(Request::all(), array('_token', '262', '261', '306', '406')); $UserData = UserData::firstOrNew(['id' => Auth::user()->id]); //test below //this adds the key/value pair to the array if it doesn't already exists, so we'll add no if they didn't select algorithms $requests = array_add($requests, 'taken_algorithms', false); $UserData->update($requests); //return $request; return view('home', compact('UserData')); //test above if ($UserData->count() == 2) { $request = array_add($request, 'id', Auth::user()->id); $request = array_add($request, 'name', Auth::user()->name); //return $request; UserData::create($request); } else { $UserData->update($request); } return view('home', compact('UserData')); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); UserData::create(['name' => $user->name, 'id' => $user->id, 'isAdmin' => 0]); return $user; }