bulk() public method

Remove the specified resource from storage.
public bulk ( $entityType = ENTITY_INVOICE ) : Response
return Response
 private function save($publicId = null)
 {
     $action = Input::get('action');
     $entityType = Input::get('entityType');
     $input = json_decode(Input::get('data'));
     if (in_array($action, ['archive', 'delete', 'mark', 'restore'])) {
         return InvoiceController::bulk($entityType);
     }
     if ($errors = $this->invoiceRepo->getErrors($input->invoice)) {
         Session::flash('error', trans('texts.invoice_error'));
         return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
     } else {
         $invoice = $this->saveInvoice($publicId, $input, $entityType);
         $url = "{$entityType}s/" . $invoice->public_id . '/edit';
         $message = trans($publicId ? "texts.updated_{$entityType}" : "texts.created_{$entityType}");
         // check if we created a new client with the invoice
         if ($input->invoice->client->public_id == '-1') {
             $message = $message . ' ' . trans('texts.and_created_client');
             $url = URL::to('clients/' . $client->public_id);
             Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
         }
         if ($action == 'clone') {
             return $this->cloneInvoice($publicId);
         } elseif ($action == 'convert') {
             return $this->convertQuote($publicId);
         } elseif ($action == 'email') {
             return $this->emailInvoice($invoice, Input::get('pdfupload'));
         }
         Session::flash('message', $message);
         return Redirect::to($url);
     }
 }
 private function save($publicId = null)
 {
     $action = Input::get('action');
     $entityType = Input::get('entityType');
     if (in_array($action, ['archive', 'delete', 'mark', 'restore'])) {
         return InvoiceController::bulk($entityType);
     }
     $input = json_decode(Input::get('data'));
     $invoice = $input->invoice;
     if ($errors = $this->invoiceRepo->getErrors($invoice)) {
         Session::flash('error', trans('texts.invoice_error'));
         return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
     } else {
         $this->taxRateRepo->save($input->tax_rates);
         $clientData = (array) $invoice->client;
         $client = $this->clientRepo->save($invoice->client->public_id, $clientData);
         $invoiceData = (array) $invoice;
         $invoiceData['client_id'] = $client->id;
         $invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
         $account = Auth::user()->account;
         if ($account->invoice_taxes != $input->invoice_taxes || $account->invoice_item_taxes != $input->invoice_item_taxes || $account->invoice_design_id != $input->invoice->invoice_design_id) {
             $account->invoice_taxes = $input->invoice_taxes;
             $account->invoice_item_taxes = $input->invoice_item_taxes;
             $account->invoice_design_id = $input->invoice->invoice_design_id;
             $account->save();
         }
         $client->load('contacts');
         $sendInvoiceIds = [];
         foreach ($client->contacts as $contact) {
             if ($contact->send_invoice || count($client->contacts) == 1) {
                 $sendInvoiceIds[] = $contact->id;
             }
         }
         foreach ($client->contacts as $contact) {
             $invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
             if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
                 $invitation = Invitation::createNew();
                 $invitation->invoice_id = $invoice->id;
                 $invitation->contact_id = $contact->id;
                 $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
                 $invitation->save();
             } elseif (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
                 $invitation->delete();
             }
         }
         $message = trans($publicId ? "texts.updated_{$entityType}" : "texts.created_{$entityType}");
         if ($input->invoice->client->public_id == '-1') {
             $message = $message . ' ' . trans('texts.and_created_client');
             $url = URL::to('clients/' . $client->public_id);
             Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
         }
         $pdfUpload = Input::get('pdfupload');
         if (!empty($pdfUpload) && strpos($pdfUpload, 'data:application/pdf;base64,') === 0) {
             $this->storePDF(Input::get('pdfupload'), $invoice);
         }
         if ($action == 'clone') {
             return $this->cloneInvoice($publicId);
         } elseif ($action == 'convert') {
             return $this->convertQuote($publicId);
         } elseif ($action == 'email') {
             if (Auth::user()->confirmed && !Auth::user()->isDemo()) {
                 if ($invoice->is_recurring) {
                     if ($invoice->shouldSendToday()) {
                         $invoice = $this->invoiceRepo->createRecurringInvoice($invoice);
                         $response = $this->mailer->sendInvoice($invoice);
                     } else {
                         $response = trans('texts.recurring_too_soon');
                     }
                 } else {
                     $response = $this->mailer->sendInvoice($invoice);
                 }
                 if ($response === true) {
                     $message = trans("texts.emailed_{$entityType}");
                     Session::flash('message', $message);
                 } else {
                     Session::flash('error', $response);
                 }
             } else {
                 $errorMessage = trans(Auth::user()->registered ? 'texts.confirmation_required' : 'texts.registration_required');
                 Session::flash('error', $errorMessage);
                 Session::flash('message', $message);
             }
         } else {
             Session::flash('message', $message);
         }
         $url = "{$entityType}s/" . $invoice->public_id . '/edit';
         return Redirect::to($url);
     }
 }