当前位置: 首页>>代码示例>>PHP>>正文


PHP UserProfile::find方法代码示例

本文整理汇总了PHP中UserProfile::find方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::find方法的具体用法?PHP UserProfile::find怎么用?PHP UserProfile::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserProfile的用法示例。


在下文中一共展示了UserProfile::find方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteProfile

 public function deleteProfile($profile)
 {
     $id = $profile->id;
     if (!$profile->delete()) {
         return false;
     }
     $profile = UserProfile::find($id);
     return empty($profile);
 }
开发者ID:Aranjedeath,项目名称:Laravel_Starter,代码行数:9,代码来源:User.php

示例2: storeProfile

 public function storeProfile()
 {
     if (Auth::check()) {
         $validation = Validator::make(Input::all(), UserProfile::$rules);
         if ($validation->fails()) {
             return Redirect::Back()->withInput()->withErrors($validation);
         }
         $profile = UserProfile::find(Auth::User()->id);
         $profile->first_name = Input::get('first_name');
         $profile->last_name = Input::get('last_name');
         $profile->save();
         return Redirect::to("user/{$profile->id}");
     } else {
         return Redirect::to('login_index');
     }
 }
开发者ID:Thormod,项目名称:JusThinkGreen,代码行数:16,代码来源:ProfileController.php

示例3: save

 public function save()
 {
     if ($this->validate()) {
         $changed = false;
         if ($this->is_new) {
             $this->password = $this->hashPassword($this->password);
             $this->password_confirmation = $this->password;
             $this->activation_code = md5(time() . $this->nickname . $this->email . rand(10000, 99999));
             $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999));
             $this->version = 1;
             $changed = true;
         } else {
             if ($this->changed_password) {
                 $this->password = $this->hashPassword($this->password);
                 $this->password_confirmation = $this->password;
             }
             if (!$this->cookie) {
                 $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999));
             }
             // Update version
             if ($this->calculateHash() != $this->hash) {
                 $this->version++;
                 $changed = true;
             }
         }
         if ($this->activated && !$this->affiliate_code) {
             $this->affiliate_code = uniqid();
         }
         $result = parent::save(self::table);
         if ($result) {
             if ($changed) {
                 Website::triggerAll($this);
             }
             $this->sync_forums();
             if ($this->activated and $this->allow_emails) {
                 $this->newzapp_signup();
             }
             $id = mysql_real_escape_string($this->id);
             $user_profile = UserProfile::find("user_profiles.user_id = '{$id}'");
             if (!$user_profile) {
                 // Create a profile for the user
                 $user_profile = new UserProfile();
                 $user_profile->user_id = $this->id;
                 $user_profile->save();
             }
         }
         return $result;
     } else {
         return false;
     }
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:51,代码来源:user.model.php

示例4: updateMyDetails

 public function updateMyDetails($userId, $data)
 {
     try {
         $user = \User::find($userId);
         $user->first_name = $data['first_name'];
         $user->last_name = $data['last_name'];
         $user->save();
         $userProfile = \UserProfile::find($userId);
         $userProfile->facebook = $data['facebook'];
         $userProfile->twitter = $data['twitter'];
         $userProfile->googleplus = $data['googleplus'];
         $userProfile->about = $data['about'];
         $userProfile->website = $data['website'];
         $userProfile->phone = $data['phone'];
         $userProfile->save();
         $userProfile = \File::delete(public_path() . '/images/profilepics/' . $userId . '.png');
         $imageResult = \App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]);
         return 'success';
     } catch (\Exception $e) {
         \Log::error('Something Went Wrong in User Repository - updateMyDetails():' . $e->getMessage());
         return 'error';
     }
 }
开发者ID:ymnl007,项目名称:92five,代码行数:23,代码来源:UserRepository.php

示例5: putEdit

 /**
  * Update the specified resource in storage.
  *
  * @param $user
  * @return Response
  */
 public function putEdit($user)
 {
     if (!Input::get('password')) {
         $rules = array('displayname' => 'required', 'email' => 'required|email', 'password' => 'min:4|confirmed', 'password_confirmation' => 'min:4');
     } else {
         $rules = array('displayname' => 'required', 'email' => 'required|email');
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $oldUser = clone $user;
         $user->displayname = Input::get('displayname');
         $user->email = Input::get('email');
         $user->confirmed = Input::get('confirm');
         $user->prepareRules($oldUser, $user);
         if ($user->confirmed == null) {
             $user->confirmed = $oldUser->confirmed;
         }
         if (!Input::get('password')) {
             $user->password = Input::get('password');
             $user->password_confirmation = Input::get('password_confirmation');
         } else {
             unset($user->password);
             unset($user->password_confirmation);
         }
         $user->amend();
         $user->saveRoles(Input::get('roles'));
         foreach (Input::get('user_profiles') as $id => $profile) {
             $pro = UserProfile::find($id);
             if (!empty($pro)) {
                 $pro->fill($profile)->push();
             } else {
                 $pro = new UserProfile($profile);
                 if ($pro->title) {
                     $user->profiles()->save($pro);
                 }
             }
         }
         foreach (Input::get('user_notes') as $id => $note) {
             $not = UserNotes::find($id);
             if (!empty($not)) {
                 if ($note) {
                     $not->fill(array('id' => $id, 'note' => $note))->push();
                 } else {
                     $not->delete();
                 }
             } else {
                 $not = new UserNotes(array('id' => $id, 'note' => $note, 'admin_id' => Confide::user()->id));
                 $user->notes()->save($not);
             }
         }
         Event::fire('controller.user.edit', array($user));
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.edit.error'))) ?: Redirect::to('admin/users/' . $user->id . '/edit')->withErrors($validator);
     }
     // Get validation errors (see Ardent package)
     $error = $user->errors()->all();
     if (empty($error)) {
         return Api::to(array('success', Lang::get('admin/users/messages.edit.success'))) ?: Redirect::to('admin/users/' . $user->id . '/edit')->with('success', Lang::get('admin/users/messages.edit.success'));
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.edit.error'))) ?: Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'));
     }
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:68,代码来源:AdminUsersController.php

示例6: postEdit

 /**
  * Update the specified resource in storage.
  *
  * @param $user
  * @return Response
  */
 public function postEdit($user)
 {
     // Validate the inputs
     $validator = Validator::make(Input::all(), User::$rules);
     if ($validator->passes()) {
         $oldUser = clone $user;
         $user->displayname = Input::get('displayname');
         $user->email = Input::get('email');
         $user->confirmed = Input::get('confirm');
         $password = Input::get('password');
         $passwordConfirmation = Input::get('password_confirmation');
         if (!empty($password)) {
             if ($password === $passwordConfirmation) {
                 $user->password = $password;
                 // The password confirmation will be removed from model
                 // before saving. This field will be used in Ardent's
                 // auto validation.
                 $user->password_confirmation = $passwordConfirmation;
             } else {
                 // Redirect to the new user page
                 return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.password_does_not_match'));
             }
         } else {
             unset($user->password);
             unset($user->password_confirmation);
         }
         if ($user->confirmed == null) {
             $user->confirmed = $oldUser->confirmed;
         }
         $user->save();
         // Save roles. Handles updating.
         $user->saveRoles(Input::get('roles'));
         foreach (Input::get('user_profiles') as $id => $profile) {
             $pro = UserProfile::find($id);
             if ($pro) {
                 $pro->fill($profile)->push();
             } else {
                 $pro = new UserProfile($profile);
                 if ($pro->title) {
                     $user->profiles()->save($pro);
                 }
             }
         }
     } else {
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'));
     }
     // Get validation errors (see Ardent package)
     $error = $user->errors()->all();
     if (empty($error)) {
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('success', Lang::get('admin/users/messages.edit.success'));
     } else {
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'));
     }
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:61,代码来源:AdminUsersController.php

示例7: postEdit

 /**
  * Edits a user
  *
  */
 public function postEdit($user)
 {
     if (!Input::get('password')) {
         $rules = array('displayname' => 'required', 'email' => 'required|email', 'password' => 'min:4|confirmed', 'password_confirmation' => 'min:4');
     } else {
         $rules = array('displayname' => 'required', 'email' => 'required|email');
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $oldUser = clone $user;
         $user->email = Input::get('email');
         $user->displayname = Input::get('displayname');
         $user->prepareRules($oldUser, $user);
         if (!Input::get('password')) {
             $user->password = Input::get('password');
             $user->password_confirmation = Input::get('password_confirmation');
         } else {
             unset($user->password);
             unset($user->password_confirmation);
         }
         $user->amend();
         foreach (Input::get('user_profiles') as $id => $profile) {
             $pro = UserProfile::find($id);
             if (!empty($pro)) {
                 $pro->fill($profile)->push();
             } else {
                 $pro = new UserProfile($profile);
                 if ($pro->title) {
                     $user->profiles()->save($pro);
                 }
             }
         }
         Event::fire('user.edit', array($user));
     } else {
         return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->withErrors($validator);
     }
     $error = $user->errors()->all();
     if (empty($error)) {
         return Redirect::to('user')->with('success', Lang::get('user/user.user_account_updated'));
     } else {
         return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->with('error', $error);
     }
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:47,代码来源:UserController.php

示例8: findModelUserProfile

 /**
  * Finds the UserProfile model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param int $id
  * @return DraftPlan the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelUserProfile($id)
 {
     if (($model = UserProfile::find(['ID_USER' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:adem-team,项目名称:advanced,代码行数:15,代码来源:DraftPlanController.php


注:本文中的UserProfile::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。