-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instruções - linkedata.txt
300 lines (254 loc) · 10.5 KB
/
Instruções - linkedata.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
ajustar o código php para fazer consulta na dbpedia e buscar informações da UF para salvar no banco de dados ajustando os códigos da Rota, Controller e View. A informação da dbpedia será visualizada na hora de editar.
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UsuariosController;
use App\Http\Controllers\AreaController;
use App\Http\Controllers\UfController;
use App\Http\Controllers\EnderecoController;
use App\Http\Controllers\GrandeareaController;
use App\Http\Controllers\SubareaController;
use App\Http\Controllers\ProgramaController;
use App\Http\Controllers\BolsaController;
use App\Http\Controllers\InstituicaoController;
use App\Http\Controllers\BeneficiarioController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\RelatorioController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
// Rota de usuários
Route::get('/usuarios', [UsuariosController::class, 'index']);
Route::get('/usuarios/cadastro', [UsuariosController::class, 'create']);
Route::post('/usuarios/salvar', [UsuariosController::class, 'store']);
Route::delete('/usuarios/{id}', [UsuariosController::class, 'destroy']);
// Rotas para áreas
Route::get('/areas', [AreaController::class, 'index']);
Route::get('/areas/cadastro', [AreaController::class, 'create']);
Route::post('/areas/salvar', [AreaController::class, 'store']);
Route::delete('/areas/{id}', [AreaController::class, 'destroy']);
Route::get('/areas/{id}/edit', [AreaController::class, 'edit']);
Route::put('/areas/{id}', [AreaController::class, 'update']);
// Rotas para Grande área
Route::get('/grandearea', [GrandeareaController::class, 'index']);
Route::get('/grandearea/cadastro', [GrandeareaController::class, 'create']);
Route::post('/grandearea/salvar', [GrandeareaController::class, 'store']);
Route::delete('/grandearea/{id}', [GrandeareaController::class, 'destroy']);
Route::get('/grandearea/{id}/edit', [GrandeareaController::class, 'edit']);
Route::put('/grandearea/{id}', [GrandeareaController::class, 'update']);
// Rotas para Sub-área
Route::get('/subarea', [SubareaController::class, 'index']);
Route::get('/subarea/cadastro', [SubareaController::class, 'create']);
Route::post('/subarea/salvar', [SubareaController::class, 'store']);
Route::delete('/subarea/{id}', [SubareaController::class, 'destroy']);
Route::get('/subarea/{id}/edit', [SubareaController::class, 'edit']);
Route::put('/subarea/{id}', [SubareaController::class, 'update']);
// Rotas para endereços
Route::get('/enderecos', [EnderecoController::class, 'index']);
Route::get('/enderecos/cadastro', [EnderecoController::class, 'create']);
Route::post('/enderecos/salvar', [EnderecoController::class, 'store']);
Route::delete('/enderecos/{id}', [EnderecoController::class, 'destroy']);
Route::get('/enderecos/{id}/edit', [EnderecoController::class, 'edit']);
Route::put('/enderecos/{id}', [EnderecoController::class, 'update']);
// Rotas para ufs
Route::get('/enderecos/ufs', [UfController::class, 'index']);
Route::get('/enderecos/ufs/cadastro', [UfController::class, 'create']);
Route::post('/enderecos/ufs/salvar', [UfController::class, 'store']);
Route::delete('/enderecos/ufs/{id}', [UfController::class, 'destroy']);
Route::get('/enderecos/ufs/{id}/edit', [UfController::class, 'edit']);
Route::put('/enderecos/ufs/{id}', [UfController::class, 'update']);
// Rotas programas
Route::get('/programa', [ProgramaController::class, 'index']);
Route::get('/programa/cadastro', [ProgramaController::class, 'create']);
Route::post('/programa/salvar', [ProgramaController::class, 'store']);
Route::delete('/programa/{id}', [ProgramaController::class, 'destroy']);
Route::get('/programa/{id}/edit', [ProgramaController::class, 'edit']);
Route::put('/programa/{id}', [ProgramaController::class, 'update']);
// Rotas bolsas
Route::get('/bolsas', [BolsaController::class, 'index']);
Route::get('/bolsas/cadastro', [BolsaController::class, 'create']);
Route::post('/bolsas/salvar', [BolsaController::class, 'store']);
Route::delete('/bolsas/{id}', [BolsaController::class, 'destroy']);
Route::get('/bolsas/{id}/edit', [BolsaController::class, 'edit']);
Route::put('/bolsas/{id}', [BolsaController::class, 'update']);
//Rotas para Instituicoes
Route::get('/instituicoes', [InstituicaoController::class, 'index']);
Route::get('/instituicoes/cadastro', [InstituicaoController::class, 'create']);
Route::post('/instituicoes/salvar', [InstituicaoController::class, 'store']);
Route::delete('/instituicoes/{id}', [InstituicaoController::class, 'destroy']);
Route::get('/instituicoes/{id}/edit', [InstituicaoController::class, 'edit']);
Route::put('/instituicoes/{id}', [InstituicaoController::class, 'update']);
// Rotas beneficiario
Route::get('/beneficiarios', [BeneficiarioController::class, 'index']);
Route::get('/beneficiarios/cadastro', [BeneficiarioController::class, 'create']);
Route::post('/beneficiarios/salvar', [BeneficiarioController::class, 'store']);
Route::delete('/beneficiarios/{id}', [BeneficiarioController::class, 'destroy']);
Route::get('/beneficiarios/{id}/edit', [BeneficiarioController::class, 'edit']);
Route::put('/beneficiarios/{id}', [BeneficiarioController::class, 'update']);
//Rotas upload
Route::get('/upload', [UploadController::class, 'showUploadForm']);
Route::post('/upload/process', [UploadController::class, 'processarArquivo']);
//Rotas de relatório
Route::get('/gerar-relatorio', [RelatorioController::class, 'gerarRelatorio']);
Controller:
<?php
namespace App\Http\Controllers;
use App\Models\Uf;
use Illuminate\Http\Request;
class UfController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$ufs = \DB::select('SELECT * FROM ufs;');
return view('ufs.index')->with('ufs', $ufs);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('ufs.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$siglaUf = $request->input('sigla');
if(\DB::insert('INSERT INTO ufs (sigla) VALUES (?)', [$siglaUf])){
return redirect('/enderecos/ufs');
}else{
return "Erro ao cadastrar";
}
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
$uf = Uf::findOrFail($id);
return view('ufs.edit')->with('uf', $uf);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
$id = $id;
$siglaUf = $request->input('sigla');
if(\DB::update("UPDATE ufs SET sigla = '" . $siglaUf ."' WHERE id = ?", [$id])){
return redirect('/enderecos/ufs')->with('msg', 'Uf editado com sucesso!');
}else{
return "Erro ao editar";
}
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
echo $id;
if(\DB::table('ufs')->where('id', $id)->delete()){
return redirect('/enderecos/ufs')->with('msg', 'Uf excluído com sucesso!');
}else{
return "Erro ao excluir";
}
}
}
View create:
<x-layout title="Novo Uf">
<div class="container" >
<h1>Cadastro de novo Uf</h1>
<p>Insira os dados abaixos para realizar o cadastro!</p>
<form action="/enderecos/ufs/salvar" method="post">
@csrf
<div class="form-group">
<div class="form-group">
<label for="sigla">Uf: </label>
<input class="form-control" class="form-control" type="text" id="sigla" name="sigla">
</div>
</div>
<div><br></div>
<button class="btn btn-primary" type="submit" >Cadastrar</button>
<div><br></div>
</form>
</div>
</x-layout>
View Edit:
<x-layout title="Editando Uf">
<div class="container" >
<h1>Editando uf</h1>
<hr>
<p>Insira os dados abaixos para realizar a atualização!</p>
<form action="/enderecos/ufs/{{$uf->id}}" method="post">
@csrf
@method('PUT')
<div class="form-group">
<div class="form-group">
<div class="row">
<div class="col">
<label for="sigla">Sigla: </label>
<input class="form-control" class="form-control" type="text" id="sigla" name="sigla" value="{{$uf->sigla}}">
</div>
</div>
<div><br></div>
<button class="btn btn-success" type="submit">Salvar</button>
</div>
<div><br></div>
</form>
</div>
</x-layout>
View index:
<x-layout title="Uf">
<div class="container" >
<h1>Lista de Ufs do sistema</h1>
<a class="btn btn-primary" href="/enderecos/ufs/cadastro">Cadastre um novo Uf</a>
<hr>
<table class="table">
<thead>
<tr>
<th scope="col">id</th>
<th scope="col">Uf</th>
<th scope="col"style="text-align: center !important;">Action</th>
</tr>
</thead>
<tbody>
@foreach ($ufs as $uf)
<tr>
<th scope="row">{{$uf->id}}</th>
<td>
{{$uf->sigla}}
</td>
<td style="text-align: center !important;display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: center;">
<a type="button" class="btn btn-outline-warning" style="margin-rigth: 3px;" href="/enderecos/ufs/{{$uf->id}}/edit">Editar</a>
<form action="/enderecos/ufs/{{$uf->id}}" method="post">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Excluir</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</x-layout>