本文整理汇总了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');
}
}
示例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);
}
}
示例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) {
}));