Skip to content

Commit e9ae643

Browse files
committedOct 27, 2017
Adition of new models, controllers and migrations for establishments, invoices and products
1 parent f53f3ae commit e9ae643

12 files changed

+398
-3
lines changed
 

‎app/Estabelecimento.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Estabelecimento extends Model
8+
{
9+
//
10+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Estabelecimento;
6+
use Illuminate\Http\Request;
7+
8+
class EstabelecimentoController extends Controller
9+
{
10+
/**
11+
* Display a listing of the resource.
12+
*
13+
* @return \Illuminate\Http\Response
14+
*/
15+
public function index()
16+
{
17+
//
18+
}
19+
20+
/**
21+
* Show the form for creating a new resource.
22+
*
23+
* @return \Illuminate\Http\Response
24+
*/
25+
public function create()
26+
{
27+
//
28+
}
29+
30+
/**
31+
* Store a newly created resource in storage.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @return \Illuminate\Http\Response
35+
*/
36+
public function store(Request $request)
37+
{
38+
//
39+
}
40+
41+
/**
42+
* Display the specified resource.
43+
*
44+
* @param \App\Estabelecimento $estabelecimento
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function show(Estabelecimento $estabelecimento)
48+
{
49+
//
50+
}
51+
52+
/**
53+
* Show the form for editing the specified resource.
54+
*
55+
* @param \App\Estabelecimento $estabelecimento
56+
* @return \Illuminate\Http\Response
57+
*/
58+
public function edit(Estabelecimento $estabelecimento)
59+
{
60+
//
61+
}
62+
63+
/**
64+
* Update the specified resource in storage.
65+
*
66+
* @param \Illuminate\Http\Request $request
67+
* @param \App\Estabelecimento $estabelecimento
68+
* @return \Illuminate\Http\Response
69+
*/
70+
public function update(Request $request, Estabelecimento $estabelecimento)
71+
{
72+
//
73+
}
74+
75+
/**
76+
* Remove the specified resource from storage.
77+
*
78+
* @param \App\Estabelecimento $estabelecimento
79+
* @return \Illuminate\Http\Response
80+
*/
81+
public function destroy(Estabelecimento $estabelecimento)
82+
{
83+
//
84+
}
85+
}

‎app/Http/Controllers/NfceController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function store(Request $request)
4747
public function show($key)
4848
{
4949
if(strlen($key)!=44)
50-
return 'Error 44';
50+
return "400";
5151

5252
$data = Nfce::get_all_data($key);
5353
return response()->json($data);
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Nota;
6+
use Illuminate\Http\Request;
7+
8+
class NotaController extends Controller
9+
{
10+
/**
11+
* Display a listing of the resource.
12+
*
13+
* @return \Illuminate\Http\Response
14+
*/
15+
public function index()
16+
{
17+
//
18+
}
19+
20+
/**
21+
* Show the form for creating a new resource.
22+
*
23+
* @return \Illuminate\Http\Response
24+
*/
25+
public function create()
26+
{
27+
//
28+
}
29+
30+
/**
31+
* Store a newly created resource in storage.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @return \Illuminate\Http\Response
35+
*/
36+
public function store(Request $request)
37+
{
38+
//
39+
}
40+
41+
/**
42+
* Display the specified resource.
43+
*
44+
* @param \App\Nota $nota
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function show(Nota $nota)
48+
{
49+
//
50+
}
51+
52+
/**
53+
* Show the form for editing the specified resource.
54+
*
55+
* @param \App\Nota $nota
56+
* @return \Illuminate\Http\Response
57+
*/
58+
public function edit(Nota $nota)
59+
{
60+
//
61+
}
62+
63+
/**
64+
* Update the specified resource in storage.
65+
*
66+
* @param \Illuminate\Http\Request $request
67+
* @param \App\Nota $nota
68+
* @return \Illuminate\Http\Response
69+
*/
70+
public function update(Request $request, Nota $nota)
71+
{
72+
//
73+
}
74+
75+
/**
76+
* Remove the specified resource from storage.
77+
*
78+
* @param \App\Nota $nota
79+
* @return \Illuminate\Http\Response
80+
*/
81+
public function destroy(Nota $nota)
82+
{
83+
//
84+
}
85+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Produto;
6+
use Illuminate\Http\Request;
7+
8+
class ProdutoController extends Controller
9+
{
10+
/**
11+
* Display a listing of the resource.
12+
*
13+
* @return \Illuminate\Http\Response
14+
*/
15+
public function index()
16+
{
17+
//
18+
}
19+
20+
/**
21+
* Show the form for creating a new resource.
22+
*
23+
* @return \Illuminate\Http\Response
24+
*/
25+
public function create()
26+
{
27+
//
28+
}
29+
30+
/**
31+
* Store a newly created resource in storage.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @return \Illuminate\Http\Response
35+
*/
36+
public function store(Request $request)
37+
{
38+
//
39+
}
40+
41+
/**
42+
* Display the specified resource.
43+
*
44+
* @param \App\Produto $produto
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function show(Produto $produto)
48+
{
49+
//
50+
}
51+
52+
/**
53+
* Show the form for editing the specified resource.
54+
*
55+
* @param \App\Produto $produto
56+
* @return \Illuminate\Http\Response
57+
*/
58+
public function edit(Produto $produto)
59+
{
60+
//
61+
}
62+
63+
/**
64+
* Update the specified resource in storage.
65+
*
66+
* @param \Illuminate\Http\Request $request
67+
* @param \App\Produto $produto
68+
* @return \Illuminate\Http\Response
69+
*/
70+
public function update(Request $request, Produto $produto)
71+
{
72+
//
73+
}
74+
75+
/**
76+
* Remove the specified resource from storage.
77+
*
78+
* @param \App\Produto $produto
79+
* @return \Illuminate\Http\Response
80+
*/
81+
public function destroy(Produto $produto)
82+
{
83+
//
84+
}
85+
}

‎app/Nfce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public static function get_all_data($key, int $just_show = 0){
187187
return $data;
188188

189189
} catch (\Illuminate\Database\QueryException $e) {
190-
return "Chave de acesso já cadastrada!";
190+
return "202";
191191
// return $e->getMessage();
192192
}
193193

‎app/Nota.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Nota extends Model
8+
{
9+
//
10+
}

‎app/Produto.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Produto extends Model
8+
{
9+
//
10+
}

‎config/database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
'collation' => 'utf8mb4_unicode_ci',
5252
'prefix' => '',
5353
'strict' => true,
54-
'engine' => null,
54+
'engine' => 'InnoDB',
5555
],
5656

5757
'pgsql' => [
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateEstabelecimentosTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('estabelecimentos', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->string('nome');
19+
$table->string('cnpj');
20+
$table->string('endereco');
21+
$table->unique(['cnpj', 'endereco'], 'k');
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
Schema::dropIfExists('estabelecimentos');
34+
}
35+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateNotasTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('notas', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('user_id')->unsigned();
19+
$table->foreign('user_id')->references('id')->on('users');
20+
$table->integer('estabelecimento_id')->unsigned();
21+
$table->foreign('estabelecimento_id')->references('id')->on('estabelecimentos');
22+
$table->string('serie');
23+
$table->date('data_emissao');
24+
$table->time('hora_emissao');
25+
$table->string('chave_acesso')->unique();
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*
33+
* @return void
34+
*/
35+
public function down()
36+
{
37+
Schema::dropIfExists('notas');
38+
}
39+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateProdutosTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('produtos', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('nfce_id')->unsigned();
19+
$table->foreign('nfce_id')->references('id')->on('notas');
20+
$table->integer('codigo');
21+
$table->string('descricao');
22+
$table->float('valor', 8, 2);
23+
$table->string('un');
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('produtos');
35+
}
36+
}

0 commit comments

Comments
 (0)
Please sign in to comment.