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