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 'activate':
                        $user->attemptActivation($user->activation_code);
                        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();
    }
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 'activate':
                        $user->attemptActivation($user->activation_code);
                        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();
    }
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 'activate' : $ user -> attemptActivation ( $ user -> activation_code ) ; 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 ( ) ; }
Perform bulk action on selected users
Perform bulk action on selected users