Skip to content

Commit 2180e26

Browse files
author
erickfirmo
committed
/**/
1 parent ae9974b commit 2180e26

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

App/Controllers/DividaDoClienteController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DividaDoClienteController extends Controller
1414
public function add()
1515
{
1616
$this->request()->validate([
17-
'divida_do_cliente_id' => 'required',
17+
'divida_id' => 'required',
1818
'cliente_id' => 'required'
1919
]);
2020

@@ -26,7 +26,7 @@ public function add()
2626
{
2727
foreach ($cliente->dividas() as $div)
2828
{
29-
if($div->id == $this->request()->input('divida_do_cliente_id'))
29+
if($div->id == $this->request()->input('divida_id'))
3030
{
3131
$hasDivida = true;
3232
}
@@ -46,7 +46,7 @@ public function add()
4646
public function store()
4747
{
4848
$divida_do_cliente = new DividaDoCliente;
49-
$divida_do_cliente->divida_id = $this->request()->input('divida_do_cliente_id');
49+
$divida_do_cliente->divida_id = $this->request()->input('divida_id');
5050
$divida_do_cliente->cliente_id = $this->request()->input('cliente_id');
5151
$divida_do_cliente->save();
5252

views/clientes/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<label for="divida_do_cliente">
6969
Dívidas
7070
<br>
71-
<select name="divida_do_cliente_id" id="divida_do_cliente" class="form-control">
71+
<select name="divida_id" id="divida_do_cliente" class="form-control">
7272
<?php
7373
foreach ($dividas as $divida)
7474
{

views/dividas/edit.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,35 @@
3737
<h3>Devedores</h3>
3838

3939
<div class="container-fluid">
40+
41+
<div class="row">
42+
<div class="col-md-12 box">
43+
<form method="POST" action="<?php route('/dividasdocliente/add/'); ?>">
44+
<input type="hidden" name="_token" value="<?php token(); ?>">
45+
46+
<label for="divida_do_cliente">
47+
Clientes
48+
<br>
49+
<select name="cliente_id" id="divida_do_cliente" class="form-control">
50+
<?php
51+
foreach ($clientes as $cliente)
52+
{
53+
echo '<option value="'.$cliente->id.'">'.$cliente->id.'. '.$cliente->nome.'</option>';
54+
}
55+
?>
56+
</select>
57+
58+
<input type="hidden" name="divida_id" value="<?php echo $divida->id; ?>">
59+
60+
61+
</label>
62+
63+
64+
<input type="submit" class="btn btn-primary" value="Adicionar Cliente">
65+
</form>
66+
</div>
67+
</div>
68+
<br>
4069
<div class="row">
4170
<div class="col-md-12">
4271
<div class="table-responsive">

0 commit comments

Comments
 (0)