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


PHP Sentinel::update方法代码示例

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


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

示例1: login

 /**
  * process the login submit.
  *
  * @return Response
  */
 public function login()
 {
     $potential_user = \Pinom\Models\User::where('email', 'LIKE', \Input::has('email') ? \Input::get('email') : '')->first();
     if (!is_null($potential_user) && trim($potential_user->password) == '') {
         //echo "isnull password!";
         $user = \Sentinel::findById($potential_user->id);
         $password = ['password' => $potential_user->id . '.' . $potential_user->email];
         $user = \Sentinel::update($user, $password);
         $activation = \Activation::create($user);
         $activation = \Activation::complete($user, $activation->code);
     }
     $credentials = ['email' => \Input::has('email') ? \Input::get('email') : '', 'password' => \Input::has('passw') ? \Input::get('passw') : ''];
     //echo '<pre>';
     //return redirect('/');
     $user = \Sentinel::authenticate($credentials);
     //print_R($user);
     if ($user = \Sentinel::check()) {
         return redirect('/login');
     } else {
         return redirect('/login');
     }
 }
开发者ID:blare,项目名称:pinom,代码行数:27,代码来源:LoginController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // dd($request);
     //get user u ant to update
     $user = \Sentinel::findById($id);
     //get the persons details
     $staff = Staff::find($request->user);
     $data = $request->except('_token');
     $rules = ['password' => 'min:4|required'];
     $validator = \Validator::make($data, $rules);
     if ($validator->passes()) {
         //array to hold final permission values
         $array_of_permissions = Helper::prepPermissions($request->exempt_permission, 'false');
         $credentials = ['email' => $staff->email, 'password' => $request->password, 'permissions' => $array_of_permissions, 'staff_id' => $staff->id, 'first_name' => $staff->fname, 'last_name' => $staff->lname];
         //update user
         $user = \Sentinel::update($user, $credentials);
         //get the id(s) of the current roles of this user in an array
         $current_roles = array();
         foreach ($user->roles as $value) {
             $current_roles[] = $value->id;
         }
         //compute role(s) to add
         $add_roles = array_diff($request->assign_roles, $current_roles);
         //compute role(s) to delete
         $delete_roles = array_diff($current_roles, $request->assign_roles);
         //update user role(s)
         $user = \Sentinel::findById($user->id);
         //add ne role(s)
         foreach ($add_roles as $role_id) {
             $role = \Sentinel::findRoleById($role_id);
             $role->users()->attach($user);
         }
         //delete role(s), if any
         foreach ($delete_roles as $role_id) {
             \DB::table('role_users')->where('role_id', $role_id)->where('user_id', $user->id)->delete();
         }
         return \Redirect::to('settings/users/create');
     } else {
         return \Redirect::back()->withInput()->withErrors($validator);
     }
 }
开发者ID:umahatokula,项目名称:academia,代码行数:48,代码来源:usersController.php

示例3: array

<?php

return array('view' => array('list' => function (array $row) {
}, 'form' => function (array $row) {
    // empty if create form
    return view('jarboe.c.users::patterns.user_password');
}), 'handle' => array('insert' => function ($idRow, $patternValue, $values) {
    $password = trim($patternValue);
    if (!$password) {
        // FIXME: translations
        throw new \Yaro\Jarboe\Exceptions\JarboeValidationException('Пароль обязательное поле');
    }
    $user = \Sentinel::findById($idRow);
    \Sentinel::update($user, compact('password'));
}, 'update' => function ($idRow, $patternValue, $values) {
    $password = trim($patternValue);
    if (!$password) {
        return;
    }
    $user = \Sentinel::findById($idRow);
    \Sentinel::update($user, compact('password'));
}, 'delete' => function ($idRow) {
}));
开发者ID:Jarboe,项目名称:Users-component,代码行数:23,代码来源:user_password.php


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