public function setCode($code) { if (is_null($code)) { $this->fv_error_message = $this->fv_error_message . '<br>- Código' . ERROR_NULL; return; } $codeZ = BusinessType::where('cod', $code)->select('cod')->first(); if (!empty($codeZ->cod)) { $this->fv_error_message = $this->fv_error_message . '<br>- Código ' . ERROR_DUPLICADO; return; } $this->cod = $code; return $this; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $client = Client::where('id', $id)->withTrashed()->with('contacts')->first(); if ($client) { //$client = Client::scope($publicId)->with('contacts')->firstOrFail(); $getTotalCredit = Credit::where('client_id', '=', $client->id)->whereNull('deleted_at')->where('balance', '>', 0)->sum('balance'); $invoices = Invoice::join('invoice_statuses', 'invoice_statuses.id', '=', 'invoices.invoice_status_id')->where('invoices.client_id', $client->id)->where('invoices.branch_id', Session::get('branch_id'))->select('invoices.invoice_number', 'invoices.invoice_date', 'invoices.importe_total', 'invoices.balance', 'invoices.due_date', 'invoice_statuses.name', 'invoices.public_id')->get(); $pagos = Payment::join('invoices', 'invoices.id', '=', 'payments.invoice_id')->join('invoice_statuses', 'invoice_statuses.id', '=', 'payments.payment_type_id')->where('payments.client_id', $client->id)->select('invoices.invoice_number', 'payments.transaction_reference', 'invoice_statuses.name', 'payments.amount', 'payments.payment_date')->get(); $creditos = Credit::where('account_id', '=', Auth::user()->account_id)->where('client_id', '=', $client->getId())->get(); $group = Group::where('id', $client->group_id)->first(); $business = BusinessType::where('id', $client->business_type_id)->first(); $data = array('title' => 'Ver Cliente', 'client' => $client, 'invoices' => $invoices, 'pagos' => $pagos, 'credit' => $getTotalCredit, 'creditos' => $creditos, 'days' => $this->getDays($client->frecuency), 'grupo' => $group->name, 'negocio' => $business->name); // return Response::json($data); return View::make('clientes.show', $data); } Session::flash('error', 'No existe el usuario'); return Redirect::to('clientes'); }