-
-
Save elton182/2412b14b1770b9839ca990dd80e3b160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('template') | |
@section('content') | |
<head> | |
<script type="text/javascript"> | |
$(document).ready(function() | |
{ | |
$("#valor").maskMoney({ | |
prefix: "R$: ", | |
decimal: ",", | |
thousands: "." | |
}); | |
}); | |
</script> | |
</head> | |
{!! Form::open(array('url' => 'pagamentos','files'=>'true', 'enctype'=>'multipart/form-data')); !!} | |
{!! csrf_field() !!} | |
<div align="center"><h3>SigeTOQ</h3></div> | |
<div align="center"><h5>Pagamento</h5></div> | |
<div class="form-group" > | |
{!!Form::label('destino_id', 'Destino:')!!}<p></p> | |
{!!Form::select('destino_id', $list_destino, null, ['class'=>'form-control'])!!} | |
</div> | |
<div class="form-group" > | |
{!!Form::label('name', 'Descrição:')!!}<p></p> | |
{!!Form::text('name', null, ['class'=>'form-control'])!!} | |
</div> | |
<div class="form-group" > | |
{!!Form::label('data', 'Data:')!!}<p></p> | |
{!!Form::date('data', \Carbon\Carbon::now());!!} | |
</div> | |
<div > | |
{!!Form::label('valor', 'Valor:')!!} | |
{!!Form::text('valor', null, ['class'=>'form-control'])!!} | |
</div><p></p> | |
<div class="form-group" > | |
{!!Form::label('situacao', 'Situação:')!!} | |
{!!Form::label('situacao', 'Pago:')!!} | |
{!!Form::checkbox('situacao','Pago')!!} | |
{!!Form::label('situacao', 'Pendente:')!!} | |
{!!Form::checkbox('situacao', 'Pendente')!!} | |
</div> | |
<div> | |
{!! Form::file('arquivo', array('class' => 'arquivo')) !!} | |
</div> | |
<div align="center"> | |
<button type="submit" class="btn btn-primary"> Salvar Pagamento</button> | |
<a href="/pagamentos" class="btn btn-primary">Cancelar</a> | |
</div> | |
{!! Form::close() !!} | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Pagamento; | |
use App\Empresa; | |
use App\Destino; | |
use Illuminate\Http\Request; | |
use DB; | |
class pagamentos extends Controller | |
{ | |
private $pagamentos, $empresa, $destino; | |
public function __construct(Pagamento $pagamentos, Empresa $empresa, Destino $destino) | |
{ | |
$this->pagamentos = $pagamentos; | |
$this->empresa = $empresa; | |
$this->destino = $destino; | |
} | |
public function index() | |
{ | |
$soma = DB::table("pagamentos")->sum('valor'); | |
$pagamentos = $this->pagamentos->orderBy('data', 'asc')->get(); | |
return view('sige.pagamentos.index', compact('pagamentos', 'soma')); | |
} | |
public function create () | |
{ | |
$list_empresa = $this->empresa->listEmpresas(); | |
$list_destino = $this->destino->listDestinos(); | |
return view ('sige.pagamentos.create', compact('list_empresa', 'list_destino')); | |
} | |
public function store(Request $request) | |
{ | |
$file = \Input::file('arquivo'); | |
$destinationPath = public_path().DIRECTORY_SEPARATOR.'uploads'; | |
$input['arquivo'] = time().'.'.$file->getClientOriginalExtension(); | |
$filename['arquivo'] =$file->getClientOriginalName(); | |
$inputs = $request->all(); | |
$inputs['valor'] = str_replace(',', '.', str_replace('.', '', $inputs['valor'])); | |
$inputs['arquivo'] = $file->move($destinationPath, $input['arquivo'], $filename['arquivo']); | |
$this->pagamentos->create($inputs); | |
return view ('/paginainicial'); | |
} | |
public function edit($id) | |
{ | |
$list_empresa = $this->empresa->listEmpresas(); | |
$list_destino = $this->destino->listDestinos(); | |
$pagamentos = Pagamento::find($id); | |
return view('sige.pagamentos.edit', compact('pagamentos', 'list_empresa', 'list_destino')); | |
} | |
public function update (Request $request, $id) | |
{ | |
$pagamentos =Pagamento::find($id); | |
$pagamentos->empresa_id = $request->empresa_id; | |
$pagamentos->destino_id = $request->destino_id; | |
$pagamentos->name = $request->name; | |
$pagamentos->valor = $request->valor = str_replace(',', '.', str_replace('.', '', $request['valor']));; | |
$pagamentos->data = $request->data; | |
$pagamentos->situacao = $request->situacao; | |
$pagamentos->save(); | |
return view('paginainicial'); | |
} | |
public function destroy($id) | |
{ | |
$pagamentos = Pagamento::find($id); | |
$pagamentos->delete(); | |
return view('paginainicial'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment