Example #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $user = new User();
     $user->fill(['name' => 'Erick Mo', 'email' => '*****@*****.**', 'password' => '123123123']);
     $user->save();
 }
Example #2
0
 private static function createUser(Hybrid_User_Profile $profile)
 {
     $user = new User();
     $data = ['email' => $profile->email ? $profile->email : null, 'name' => $profile->displayName, 'avatar' => $profile->photoURL, 'country' => $profile->country, 'gender' => $profile->gender, 'region' => $profile->region, 'phone' => $profile->phone, 'city' => $profile->city, 'address' => $profile->address, 'birthday' => $profile->birthYear . '-' . $profile->birthMonth . '-' . $profile->birthDay, 'language' => $profile->language];
     $user->fill($data);
     $user->token = md5(sha1(\Config::get('app.key') . microtime() . rand()));
     $user->save();
     return $user;
 }
 public function register($data)
 {
     $roleUser = Role::getRoleByName('user');
     $user = new User();
     $user->fill($data);
     $user->setAttribute('status', true);
     $user->setAttribute('role_id', $roleUser->id);
     return $user->save();
 }
 /**
  *
  */
 public function store(CreateUserRequest $request)
 {
     $user = new User();
     $user->fill($request->all());
     $user->company_id = Auth::user()->company_id;
     $user->password = bcrypt($request->input('password'));
     $user->save();
     Flash::success(trans('users/general.status.created'));
     return redirect('/users');
 }
Example #5
0
 public function store(array $input)
 {
     $user = new User();
     $user->fill($input);
     $user = $this->setPassword($user, $input);
     $user->save();
     $this->linkToRole($user, $input);
     $this->linkToFaculty($user, $input);
     return $user;
 }
Example #6
0
 public function doAdd(Request $request)
 {
     $user_form = $request->get('user');
     $user = new User();
     $user->fill($user_form);
     $user->password = Hash::make($user_form['password']);
     $user->faculty_id = $user_form["faculty_id"];
     $user->save();
     $user->roles()->sync($user_form["role_ids"]);
     return redirect('/backend/user');
 }
 public function store(Request $request)
 {
     $user = new User();
     $user->fill($request->all());
     $user->password = Hash::make($request->get('password'));
     if ($request->get('name') == "" || $request->get('email') == "" || $request->get('password') == "") {
         $request->session()->flash('error', 'Something was left blank');
         return redirect('/register');
     } else {
         Auth::login($user);
         return redirect('/#/editUser/' . $user->id);
     }
 }
 public function register(Request $request)
 {
     $fields = array('email', 'password');
     foreach ($fields as $field) {
         if (!$request->input($field)) {
             return response()->json(array('error' => 'Missing field: ' . $field), 400);
         }
     }
     if (User::where('email', '=', $request->input('email'))->first()) {
         return response()->json(array('error' => 'An account already exists with this email address.'), 400);
     }
     $user = new User();
     $user->fill($request->all());
     $user->password = User::hashedPassword($request->input('password'));
     $user->save();
     return $this->login($request);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $user = new User();
     $user->fill($request->all());
     $user->status_level = 0;
     $user->password = \Hash::make($request->password);
     $user->save();
     $scores = new Score();
     $scores->user_id = $user->id;
     $scores->value = 0;
     $scores->save();
     \Mail::send('emails.new_user', ['user' => $user], function ($message) use($user) {
         $message->to("*****@*****.**", $user->name)->subject(trans('emails.new_user_title'));
     });
     \Auth::attempt(array('email' => $request->email, 'password' => $request->password));
     return redirect()->intended('/profile');
 }
Example #10
0
 /**
  * Store user
  *
  * @param array $data            
  * @throws NotFoundException, ValidationException
  * @return \App\Models\UserModel
  */
 public function store($data)
 {
     if (!array_get($data, 'password')) {
         unset($data['password']);
     }
     try {
         if (array_get($data, 'id')) {
             $user = UserModel::findOrFail((int) array_get($data, 'id'));
             // if this user's email is the same as what the data, then it's ok; otherwise, it has to be unique
             if (array_get($data, 'email') && $user->email == array_get($data, 'email')) {
                 $user->removeRule('email');
             }
             $user->fill($data);
         } else {
             $user = new UserModel();
             $user->fill($data);
         }
     } catch (Exception $e) {
         throw new NotFoundException(trans('app.notFound'));
     }
     if (!array_get($data, 'password')) {
         $user->removeRule('password');
     }
     if (!$user->validate()) {
         throw new ValidationException(trans('app.correctErrors'), $user->errors()->toArray());
     }
     if (array_get($data, 'password')) {
         $user->password = bcrypt($data['password']);
     }
     unset($user->password_confirmation);
     try {
         $user->save();
     } catch (Exception $e) {
         throw $e;
     }
     return $user;
 }
Example #11
0
 /**
  * This method save or log in a user when is using FacebookAccount
  * @param $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 private function loginFacebookUser($request)
 {
     //load the facebook SDK object
     $fb = new Facebook(['app_id' => env('FB_API_ID'), 'app_secret' => env('FB_API_SECRET'), 'default_graph_version' => 'v2.2']);
     //set the token that whe receive from the request APP
     $fb->setDefaultAccessToken($request->input('token'));
     //Get the graph query
     try {
         $response = $fb->get('/me?fields=id,name,email');
         $fbUser = $response->getGraphUser();
     } catch (FacebookResponseException $e) {
         return response()->json($e->getMessage(), 401);
     } catch (FacebookSDKException $e) {
         return response()->json($e->getMessage(), 400);
     }
     //instantiate the new user
     $user = new User();
     //find by facebook_id and get the mongodb collection for users
     $users = $user->getCollection();
     $result = $users->findOne(['facebook_id' => $fbUser['id']]);
     if ($result) {
         var_dump('log in process by idfb');
         die;
     }
     //find by email
     $result = $users->findOne(['email' => $fbUser['email']]);
     if ($result) {
         var_dump('log in process by email');
         die;
     }
     //if not found then fill data and save account
     $user->fill($request);
     if (!$user->save()) {
         return response()->json('Error, the user was not created', 400);
     }
     return response()->json('success', 200);
 }
Example #12
0
 public function postUserUnban(User $user)
 {
     $user->fill(['banned' => false])->save();
     flash()->success(trans('messages.admin.unbanned_user', ['name' => $user->name]));
     return redirect()->back();
 }
Example #13
0
 /**
  * Update user
  *
  * @param User $user
  * @param array $data
  */
 public static function update(User $user, $data = array())
 {
     $user->fill($data);
     $user->update();
 }
 public function update(User $user, Request $request)
 {
     $user->fill($request->input())->save();
     return redirect()->route('users.index');
 }
Example #15
0
 /**
  * store a resource 
  * @param  Request 	$this->request http request
  * @param  mixed  	$id      id of the resource for updating
  * @return jsend           	 jsend with newly stored source
  */
 function store($id = null)
 {
     ////////////////
     // Load Data  //
     ////////////////
     if ($id) {
         $data = Model::find($id);
         if (!$data) {
             return app()->abort(404);
         }
     } else {
         $data = new Model();
     }
     ///////////////////////////////////
     // Assign posted data to Data    //
     ///////////////////////////////////
     $data->fill($this->request->input());
     ///////////////////////
     // EMBED IMAGES 	 //
     ///////////////////////
     foreach ($this->request->input('images') as $x) {
         $images[] = new Image($x);
     }
     if (!$data->syncImages($images)) {
         return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
     }
     ///////////////////////
     // EMBED AUTH    	 //
     ///////////////////////
     foreach ($this->request->input('auths') as $x) {
         $auths[] = new Auth($x);
     }
     if (!$data->syncAuths($auths)) {
         return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
     }
     ///////////////////////
     // EMBED ACCOUNT  	 //
     ///////////////////////
     foreach ($this->request->input('account_connects') as $x) {
         $accounts[] = new AccountConnect($x);
     }
     if (!$data->syncAccountConnects($accounts)) {
         return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
     }
     ///////////
     // Store //
     ///////////
     if ($data->save()) {
         /////////////////////
         // Return Response //
         /////////////////////
         return response()->json(JSend::success(['data' => $data->toArray()])->asArray());
     } else {
         return response()->json(JSend::fail($data->getErrors())->asArray());
     }
 }