public function edit($publicId) { $payment = Payment::scope($publicId)->firstOrFail(); $payment->payment_date = Utils::fromSqlDate($payment->payment_date); $data = array('client' => null, 'invoice' => null, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->with('client', 'invoice_status')->orderBy('invoice_number')->get(), 'payment' => $payment, 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => 'Edit Payment', 'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function bulk() { $public_id = Input::get('public_id'); $payment = Payment::scope($public_id)->first(); $payment->delete(); $message = "Pago eliminado con éxito"; Session::flash('message', $message); return Redirect::to('pagos'); }
public function index() { if (!Utils::isPro()) { return Redirect::to('/'); } $payments = Payment::scope()->orderBy('created_at', 'desc')->get(); $payments = Utils::remapPublicIds($payments->toArray()); $response = json_encode($payments, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(count($payments)); return Response::make($response, 200, $headers); }
private function export() { $output = fopen('php://output', 'w') or Utils::fatalError(); header('Content-Type:application/csv'); header('Content-Disposition:attachment;filename=export.csv'); $clients = Client::scope()->get(); AccountController::exportData($output, $clients->toArray()); $contacts = Contact::scope()->get(); AccountController::exportData($output, $contacts->toArray()); $invoices = Invoice::scope()->get(); AccountController::exportData($output, $invoices->toArray()); $invoiceItems = InvoiceItem::scope()->get(); AccountController::exportData($output, $invoiceItems->toArray()); $payments = Payment::scope()->get(); AccountController::exportData($output, $payments->toArray()); $credits = Credit::scope()->get(); AccountController::exportData($output, $credits->toArray()); fclose($output); exit; }