public function deleteUser(\Request $request) { $user = \p4\User::find($request::get('user_id')); $user->delete(); \Session::flash('message', 'User has been successfully deleted.'); return redirect()->back(); }
public function postRegister(Request $request) { # Get the input from the registration form $userName = $request->input('user-name'); $password = $request->input('password'); $passwordConfirm = $request->input('password-confirm'); $email = $request->input('email-address'); $userExists = \p4\User::where('user_name', $userName)->orwhere('email', $email)->exists(); $input = array('email' => $email, 'password' => $password, 'password_confirmation' => $passwordConfirm, 'user_name' => $userName); $rules = ['user_name' => 'required|min:3|max:30|unique:users', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6|max:20']; $validator = \Validator::make($input, $rules); if ($validator->fails()) { return redirect('Register')->withErrors($validator)->withInput(); } if (!$userExists) { # Register this User $newUser = \p4\User::create(['user_name' => $userName, 'password' => bcrypt($password), 'status' => 'A', 'email' => $email]); # Create Default My Feeds Category $default = new \p4\Category(); $default->user_id = $newUser->id; $default->name = "My Feeds"; $default->weight = 50; $default->save(); $message = "You have been registered. Please login to continue."; } return view('login', ['message' => $message]); }
/** * Run the database seeds. * * @return void */ public function run() { factory(P4\User::class, 2)->create(); $user = \P4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jill'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); $user = \P4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jamal'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); }
/** * Return user if exists; create and return if doesn't * * @param $fbUser * @return User */ private function findOrCreateUser($fbUser) { //check if FB account already exists if ($authUser = User::where('facebook_id', $fbUser->id)->first()) { return $authUser; } //if FBUser's email is the same as an user's email account, directly log in as that user $user = User::where('email', $fbUser->email)->first(); if (sizeof($user) > 0) { //user account exists with same email addresss return $user; } return User::create(['name' => $fbUser->name, 'email' => $fbUser->email, 'facebook_id' => $fbUser->id]); }
/** * Run the database seeds. * * @return void */ public function run() { $kids = ['John' => ['Jill', 'Jamal', 'Jean'], 'Jasper' => ['Jean'], 'Olivia' => ['Jill', 'Jean'], 'Emily' => ['Jamal', 'Jean']]; # Now loop through the above array, creating a new pivot for each kid corresponding to user foreach ($kids as $name => $users) { # First get the kid name matched $kid = \P4\Kid::where('name', 'like', $name)->first(); # Loop through all users for each kid foreach ($users as $userName) { $user = \P4\User::where('name', 'like', $userName)->first(); # Save the kid's users info $kid->users()->save($user); } } }
/** * Run the database seeds. * * @return void */ public function run() { $faker = \Faker\Factory::create(); foreach (range(1, 7) as $index) { User::create(['name' => $faker->name(), 'email' => $faker->email(), 'password' => \Hash::make('helloworld'), 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString()]); } $user = \p4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jill'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); $user = \p4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jamal'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); }
/** * Run the database seeds. * * @return void */ public function run() { $user = \P4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jill'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); $user = \P4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jamal'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); $user = \P4\User::firstOrCreate(['email' => '*****@*****.**']); $user->name = 'Jean'; $user->email = '*****@*****.**'; $user->password = \Hash::make('helloworld'); $user->save(); }
/** * Run the database seeds. * * @return void */ public function run() { # First, create an array of all the users we want to associate kids with # The *key* will be the user email, and the *value* will be an array of tags. $users = ['*****@*****.**' => ['Julius', 'Pah'], '*****@*****.**' => ['Brett', 'Mary', 'Jus']]; # Now loop through the above array, creating a new pivot for each user to kid foreach ($users as $email => $kids) { # First get the user $user = \p4\User::where('email', 'like', $email)->first(); echo nl2br("user " . $user . "\n"); # Now loop through each kid for this book, adding the pivot foreach ($kids as $firstname) { echo nl2br("firstname " . $firstname . "\n"); $kid = \p4\Kid::where('firstname', 'LIKE', $firstname)->first(); # Connect this user to this kid $user->kids()->attach($kid); } } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
public function getRemoveTag(Request $request, $tag_id) { $user_id = \Auth::user()->id; \p4\Tag::where('id', '=', $tag_id)->where('user_id', '=', $user_id)->delete(); \p4\User::setSessionFeeds($user_id); return \Redirect::to('/ManageTags'); }