From fd3e4a67cf5dde2a29ab2171b533e35bd7665ea9 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 9 Sep 2018 00:26:57 -0300 Subject: [PATCH] Including Item and Product migration, controllers and models --- app/Http/Controllers/ItemController.php | 23 ++++++++++++ app/Http/Controllers/ProductController.php | 23 ++++++++++++ app/Item.php | 18 ++++++++++ app/Product.php | 10 ++++++ ...018_09_08_192040_create_products_table.php | 33 +++++++++++++++++ .../2018_09_08_192152_create_items_table.php | 35 +++++++++++++++++++ readme.md | 2 +- resources/views/item.blade.php | 7 ++++ resources/views/product.blade.php | 6 ++++ routes/web.php | 12 +++---- 10 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 app/Http/Controllers/ItemController.php create mode 100644 app/Http/Controllers/ProductController.php create mode 100644 app/Item.php create mode 100644 app/Product.php create mode 100644 database/migrations/2018_09_08_192040_create_products_table.php create mode 100644 database/migrations/2018_09_08_192152_create_items_table.php create mode 100644 resources/views/item.blade.php create mode 100644 resources/views/product.blade.php diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php new file mode 100644 index 0000000..c8d9eda --- /dev/null +++ b/app/Http/Controllers/ItemController.php @@ -0,0 +1,23 @@ +where([ + ['productID', $productID], + ['usedBy', ''], + ]); + } + +} diff --git a/app/Product.php b/app/Product.php new file mode 100644 index 0000000..8dee5b2 --- /dev/null +++ b/app/Product.php @@ -0,0 +1,10 @@ +increments('id'); + $table->string('name'); + $table->integer('adminID'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('products'); + } +} diff --git a/database/migrations/2018_09_08_192152_create_items_table.php b/database/migrations/2018_09_08_192152_create_items_table.php new file mode 100644 index 0000000..4b53636 --- /dev/null +++ b/database/migrations/2018_09_08_192152_create_items_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('name'); + $table->integer('productID'); + $table->integer('usedBy'); + $table->dateTime('usedSince'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('items'); + } +} diff --git a/readme.md b/readme.md index 32a10c9..69592a9 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ Cada usuário, identificado por e-mail, pode ter outros amigos usuário(nome, email) product[site/software](nome, admin) -userPerProduct(productID, userID) +productUsers(productID, userID) item[licença](nome, productID, usedBy, usedSince) waiting(userID, itemID, waitingSince) diff --git a/resources/views/item.blade.php b/resources/views/item.blade.php new file mode 100644 index 0000000..dbf1c00 --- /dev/null +++ b/resources/views/item.blade.php @@ -0,0 +1,7 @@ + +

Item!

+
+ @if (isset($item)) + Item: {{$item}} + @endif + \ No newline at end of file diff --git a/resources/views/product.blade.php b/resources/views/product.blade.php new file mode 100644 index 0000000..82ece44 --- /dev/null +++ b/resources/views/product.blade.php @@ -0,0 +1,6 @@ + +

Product!

+@if (isset($productID)) + {{$productID}} +@endif + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 1e1318c..6da7d24 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,11 +16,7 @@ Route::get('/', function () { return view('welcome', compact('name')); }); -Route::get('/product/{id}', function () { - $productID = DB::table('product')->find($id); - return view('product', compact['productID']); -}); - -Route::get('/item/{id}', function () { - return view('item'); -}); \ No newline at end of file +Route::get('/product', 'ProductController@index'); +Route::get('/product/{product}', 'ProductController@show'); +Route::get('/item', 'ItemController@index'); +Route::get('/item/{item}', 'ItemController@show'); \ No newline at end of file