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


PHP Company::getIdForUser方法代码示例

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


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

示例1: postEdit

 /**
  * Validate and save edited user data from edit form.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v1.0]
  * @param  int  $id
  * @return Redirect
  */
 public function postEdit(UpdateUserRequest $request, $id = null)
 {
     // We need to reverse the UI specific logic for our
     // permissions here before we update the user.
     $permissions = $request->input('permissions', array());
     app('request')->request->set('permissions', $permissions);
     // Only update the email address if locking is set to false
     if (config('app.lock_passwords')) {
         return redirect()->route('users')->with('error', 'Denied! You cannot update user information on the demo.');
     }
     try {
         // Get the user information
         $user = User::find($id);
         if (!Company::isCurrentUserHasAccess($user)) {
             return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
         }
     } catch (UserNotFoundException $e) {
         // Prepare the error message
         $error = trans('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return redirect()->route('users')->with('error', $error);
     }
     // First handle anything exclusive to editing.
     if ($request->has('groups')) {
         $user->groups()->sync($request->input('groups'));
     } else {
         $user->groups()->sync(array());
     }
     // Do we want to update the user password?
     if ($request->has('password')) {
         $user->password = bcrypt($request->input('password'));
     }
     if ($request->has('username')) {
         $user->username = e($request->input('username'));
     }
     $user->email = e($request->input('email'));
     // Update the user
     $user->first_name = e($request->input('first_name'));
     $user->last_name = e($request->input('last_name'));
     $user->locale = e($request->input('locale'));
     $user->employee_num = e($request->input('employee_num'));
     $user->activated = e($request->input('activated', $user->activated));
     $user->jobtitle = e($request->input('jobtitle'));
     $user->phone = e($request->input('phone'));
     $user->location_id = e($request->input('location_id'));
     $user->company_id = e(Company::getIdForUser($request->input('company_id')));
     $user->manager_id = e($request->input('manager_id'));
     $user->notes = e($request->input('notes'));
     $user->permissions = json_encode($request->input('permission'));
     if ($user->manager_id == "") {
         $user->manager_id = null;
     }
     if ($user->location_id == "") {
         $user->location_id = null;
     }
     if ($user->company_id == "") {
         $user->company_id = null;
     }
     // Was the user updated?
     if ($user->save()) {
         // Prepare the success message
         $success = trans('admin/users/message.success.update');
         // Redirect to the user page
         return redirect()->route('users')->with('success', $success);
     }
     return redirect()->back()->withInput()->withErrors($user->getErrors());
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:75,代码来源:UsersController.php


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