function add_user($username, $email, $password, $role = 'subscriber', $name = '', $activated = 1) { $options = new User(); $options->username = $username; $options->email = $email; $options->password = Hash::make($password); $options->role = $role; $options->name = $name; $options->activated = $activated; $options->save(); }
public function edit($id) { if ($this->data['user']->id != $id) { exit; } if (User::where('username', trim(Input::get('username')))->where('id', '<>', $id)->count() > 0) { return json_encode(array("jsTitle" => "Edit Profile", "jsStatus" => "0", "jsMessage" => "Username already used")); exit; } if (User::where('email', Input::get('email'))->where('id', '<>', $id)->count() > 0) { return json_encode(array("jsTitle" => "Edit Profile", "jsStatus" => "0", "jsMessage" => "Email already used")); exit; } $pw = Input::get('password'); if (null !== $pw && $pw != Input::get('password_confirmation')) { return json_encode(array("jsTitle" => "Password", "jsStatus" => "0", "jsMessage" => "Passwords do not match")); exit; } if (strlen($pw) > 0 && strlen($pw) < 6) { return json_encode(array("jsTitle" => "Password", "jsStatus" => "0", "jsMessage" => "Password should be at least 6 characters long")); exit; } $User = User::find($id); $User->username = Input::get('username'); $User->email = Input::get('email'); $User->name = Input::get('name'); //$User->save(); return json_encode(array("jsTitle" => "Edit Profile", "jsStatus" => "1", "jsMessage" => "Profile edited successfully")); exit; }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $role = isset($data['seller']) ? 'seller' : 'customer'; return User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'role' => $role, 'name' => $data['name'], 'activated' => 0]); }