public function massUpdate(UsersRequest $request, User $users)
    {
        $this->authorize('otherUpdate', User::class);

        $data = $request->except('_token', 'updated_at', 'image', 'submit');
        $users = $users->whereIn('id', $data['users']);
        $messages = [];

        switch ($data['mass_action']) {
            case 'mass_activate':
                // if (! $users->update(['approve' => 1])) {
                //     $messages[] = '!mass_activate';
                // }
                break;
            case 'mass_lock':
                // if (! $users->update(['approve' => 0])) {
                //     $messages[] = '!mass_lock';
                // }
                break;
            case 'mass_delete':
                $usersTemp = $users->get();
                foreach ($usersTemp as $user) {
                    if (! $user->delete()) {
                        $messages[] = '!mass_delete';
                    }
                }
                break;
            case 'mass_delete_inactive':
                // if (! $users->update(['on_mainpage' => 1])) {
                //     $messages[] = '!mass_delete_inactive';
                // }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.users.index', $message);
    }
public function massUpdate(UsersRequest $request, User $users)
    {
        $this->authorize('otherUpdate', User::class);

        $data = $request->except('_token', 'updated_at', 'image', 'submit');
        $users = $users->whereIn('id', $data['users']);
        $messages = [];

        switch ($data['mass_action']) {
            case 'mass_activate':
                // if (! $users->update(['approve' => 1])) {
                //     $messages[] = '!mass_activate';
                // }
                break;
            case 'mass_lock':
                // if (! $users->update(['approve' => 0])) {
                //     $messages[] = '!mass_lock';
                // }
                break;
            case 'mass_delete':
                $usersTemp = $users->get();
                foreach ($usersTemp as $user) {
                    if (! $user->delete()) {
                        $messages[] = '!mass_delete';
                    }
                }
                break;
            case 'mass_delete_inactive':
                // if (! $users->update(['on_mainpage' => 1])) {
                //     $messages[] = '!mass_delete_inactive';
                // }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.users.index', $message);
    }
public function massUpdate ( UsersRequest $ request , User $ users ) { $ this -> authorize ( 'otherUpdate' , User :: class ) ; $ data = $ request -> except ( '_token' , 'updated_at' , 'image' , 'submit' ) ; $ users = $ users -> whereIn ( 'id' , $ data [ 'users' ] ) ; $ messages = [ ] ; switch ( $ data [ 'mass_action' ] ) { case 'mass_activate' : // if (! $users->update(['approve' => 1])) { //     $messages[] = '!mass_activate'; // } break ; case 'mass_lock' : // if (! $users->update(['approve' => 0])) { //     $messages[] = '!mass_lock'; // } break ; case 'mass_delete' : $ usersTemp = $ users -> get ( ) ; foreach ( $ usersTemp as $ user ) { if ( ! $ user -> delete ( ) ) { $ messages [ ] = '!mass_delete' ; } } break ; case 'mass_delete_inactive' : // if (! $users->update(['on_mainpage' => 1])) { //     $messages[] = '!mass_delete_inactive'; // } break ; } $ message = empty ( $ messages ) ? 'msg.complete' : 'msg.complete_but_null' ; return $ this -> makeRedirect ( true , 'admin.users.index' , $ message ) ; }
Mass update the specified resource in storage.

@param  \BBCMS\Http\Requests\Admin\UsersRequest  $request
@param  \BBCMS\Models\User  $users
@return \Illuminate\Http\Response
Mass update the specified resource in storage .