public function bulkDelete(Request $request)
    {
        if(!User::hasAccess('Language', 'delete')) {
            return $this->noPermission();
        }

        // Ensure a selection has taken place
        if (count($request->all()) <= 0) {
            return $this->response('Please select some languages to be deleted', 500);
        }

        $allPostTypes = PostType::all();

        // loop through language IDs
        foreach ($request->all() as $id) {
            $language = Language::find($id);

            if ($language->isDefault) {
                return $this->response("You can't delete the default language!", 403);
            }

            if(!$language->delete()) {
                return $this->response('The language '.$language->languageID.' was not deleted so the deleting process has stopped. Please try again later', 500);
            }else{
                // create virutal column for slug of every post type in the created language
                foreach ($allPostTypes as $postType){
                    AccioQuery::deleteColumn($postType->slug, "slug_".$language->slug);
                }

                $this->deleteDirectory($language->slug);
            }
        }
        return $this->response('Languages are deleted');
    }
public function bulkDelete(Request $request)
    {
        if(!User::hasAccess('Language', 'delete')) {
            return $this->noPermission();
        }

        // Ensure a selection has taken place
        if (count($request->all()) <= 0) {
            return $this->response('Please select some languages to be deleted', 500);
        }

        $allPostTypes = PostType::all();

        // loop through language IDs
        foreach ($request->all() as $id) {
            $language = Language::find($id);

            if ($language->isDefault) {
                return $this->response("You can't delete the default language!", 403);
            }

            if(!$language->delete()) {
                return $this->response('The language '.$language->languageID.' was not deleted so the deleting process has stopped. Please try again later', 500);
            }else{
                // create virutal column for slug of every post type in the created language
                foreach ($allPostTypes as $postType){
                    AccioQuery::deleteColumn($postType->slug, "slug_".$language->slug);
                }

                $this->deleteDirectory($language->slug);
            }
        }
        return $this->response('Languages are deleted');
    }
public function bulkDelete ( Request $ request ) { if ( ! User :: hasAccess ( 'Language' , 'delete' ) ) { return $ this -> noPermission ( ) ; } // Ensure a selection has taken place if ( count ( $ request -> all ( ) ) <= 0 ) { return $ this -> response ( 'Please select some languages to be deleted' , 500 ) ; } $ allPostTypes = PostType :: all ( ) ; // loop through language IDs foreach ( $ request -> all ( ) as $ id ) { $ language = Language :: find ( $ id ) ; if ( $ language -> isDefault ) { return $ this -> response ( "You can't delete the default language!" , 403 ) ; } if ( ! $ language -> delete ( ) ) { return $ this -> response ( 'The language ' . $ language -> languageID . ' was not deleted so the deleting process has stopped. Please try again later' , 500 ) ; } else { // create virutal column for slug of every post type in the created language foreach ( $ allPostTypes as $ postType ) { AccioQuery :: deleteColumn ( $ postType -> slug , "slug_" . $ language -> slug ) ; } $ this -> deleteDirectory ( $ language -> slug ) ; } } return $ this -> response ( 'Languages are deleted' ) ; }
Bulk Delete languages.

Delete many languages

@params array Language IDs
Bulk Delete languages .