public function store(BoletosRequest $request) { $lancamentos = $request->all(); $lancamentos['tipo'] = 'bo'; if ($lancamentos['data_pagamento'] == '') { unset($lancamentos['data_pagamento']); } $lanc = Lancamento::create($lancamentos); $boleto = $request->boletos; $boleto['lancamento_id'] = $lanc->id; Boleto::create($boleto); flash()->success('Boleto cadastrado com sucesso'); return redirect()->route('boletos.index'); }
private function insertBoletos($venda, $boletos) { foreach ($boletos as $value) { //dd($value); $value['descricao'] = 'Boleto nº ' . $value['num_boleto']; if ($value['id'] != '') { $lanc = Lancamento::find($value['id']); $lanc->update($value); $lanc->boleto()->update(['numero' => $value['num_boleto']]); } else { $lanc = $venda->lancamentos()->create($value); Boleto::create(['numero' => $value['num_boleto'], 'lancamento_id' => $lanc->id, 'cliente_id' => $value['cliente_id']]); } } }
public function boleto(Request $request) { $cliente = Venda::find($request->boleto['venda_id'])->cliente_id; $boleto = $request->boleto; $boleto['descricao'] = 'Boleto nº ' . $request->boleto['boleto_num']; $boleto['tipo'] = 'bo'; $lancamento = Lancamento::create($boleto); Boleto::create(['numero' => $boleto['boleto_num'], 'lancamento_id' => $lancamento->id, 'cliente_id' => $cliente]); return $this->getValuesTable($request->boleto['venda_id'], 'bo'); }