本文整理汇总了PHP中RainLab\User\Models\User::withTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP User::withTrashed方法的具体用法?PHP User::withTrashed怎么用?PHP User::withTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RainLab\User\Models\User
的用法示例。
在下文中一共展示了User::withTrashed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
public function up()
{
Schema::table('users', function ($table) {
$table->string('login')->nullable()->index();
});
/*
* Set login for existing users
*/
$users = User::withTrashed()->get();
foreach ($users as $user) {
$user->login = $user->email;
$user->save();
}
Schema::table('users', function ($table) {
$table->unique('login');
});
}
示例2: index_onBulkAction
/**
* Perform bulk action on selected users
*/
public function index_onBulkAction()
{
if (($bulkAction = post('action')) && ($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
foreach ($checkedIds as $userId) {
if (!($user = User::withTrashed()->find($userId))) {
continue;
}
switch ($bulkAction) {
case 'delete':
$user->forceDelete();
break;
case 'deactivate':
$user->delete();
break;
case 'restore':
$user->restore();
break;
case 'ban':
$user->ban();
break;
case 'unban':
$user->unban();
break;
}
}
Flash::success(Lang::get('rainlab.user::lang.users.' . $bulkAction . '_selected_success'));
} else {
Flash::error(Lang::get('rainlab.user::lang.users.' . $bulkAction . '_selected_empty'));
}
return $this->listRefresh();
}