/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($id)
 {
     $venda = Venda::find($id);
     $total = $venda->totalVenda($id);
     $entradas = Lancamento::where('venda_id', $id)->where('tipo', 'en')->get();
     $descontos = Lancamento::where('venda_id', $id)->where('tipo', 'dc')->get();
     $boletos = Lancamento::with('boleto')->where('venda_id', $id)->where('tipo', 'bo')->get();
     $cheques = Lancamento::where('venda_id', $id)->where('tipo', 'ch')->leftJoin('cheques', 'cheques.lancamento_id', '=', 'lancamentos.id')->leftJoin('bancos', 'cheques.banco_id', '=', 'bancos.id')->select('lancamentos.id', 'lancamentos.valor', 'lancamentos.descricao', 'lancamentos.data_vencimento', 'lancamentos.tipo', 'cheques.id as cheque_id', 'cheques.banco_id', 'cheques.numero', 'cheques.nome as nome_cheque', 'bancos.nome as nome_banco')->get();
     $bancos = Banco::with('cheques')->orderBy('nome')->select('nome', 'id')->get();
     return view('lancamentos.create', compact('venda', 'total', 'entradas', 'boletos', 'cheques', 'bancos', 'descontos'));
 }
 public function create($id)
 {
     $venda = Venda::find($id);
     $lancamento = Lancamento::where('venda_id', $id);
     $total = $this->getValorTotalLancamentos($id);
     //$lancamento->sum('valor_pago') + $venda->adiantamento - $lancamento->sum('desconto');
     $entradas = Lancamento::where('venda_id', $id)->where('tipo', 'en')->get();
     $descontos = Lancamento::where('venda_id', $id)->where('tipo', 'dc')->get();
     $boletos = Lancamento::with('boleto')->where('venda_id', $id)->where('tipo', 'bo')->get();
     $cheques = Lancamento::with('cheque')->where('venda_id', $id)->where('tipo', 'ch')->get();
     $bancos = Banco::with('cheques')->orderBy('nome')->select('nome', 'id')->get();
     return view('lancamentos.create', compact('venda', 'total', 'entradas', 'descontos', 'boletos', 'cheques', 'bancos'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(BancosRequest $request, $id)
 {
     Banco::find($id)->update($request->all());
     flash()->success('Banco atualizado com sucesso');
     return redirect('/bancos');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $cheque = Cheque::find($id);
     $bancos = Banco::all()->lists('nome', 'id');
     $clientes = Cliente::orderBy('fantasia')->get();
     $fornecedores = Fornecedor::orderBy('fantasia')->get();
     if ($cheque->lancamento->status != '2' || $cheque->lancamento->status != '3') {
         return view('cheques.edit', compact('cheque', 'bancos', 'clientes', 'fornecedores'));
     }
     flash('Cheque já está pago');
     return redirect('/cheques');
 }