App\Http\Controllers\InvoiceController::bulk PHP Method

bulk() public method

Remove the specified resource from storage.
public bulk ( $entityType = ENTITY_INVOICE ) : Response
return Response
    public function bulk($entityType = ENTITY_INVOICE)
    {
        $action = Input::get('bulk_action') ?: Input::get('action');
        $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
        $count = $this->invoiceService->bulk($ids, $action);
        if ($count > 0) {
            $key = $action == 'markSent' ? "updated_{$entityType}" : "{$action}d_{$entityType}";
            $message = Utils::pluralize($key, $count);
            Session::flash('message', $message);
        }
        return $this->returnBulk($entityType, $action, $ids);
    }

Usage Example

 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);
     }
 }
All Usage Examples Of App\Http\Controllers\InvoiceController::bulk