summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel Schuurmans <michielschuurmans@gmail.com>2020-10-01 21:40:23 +0200
committerMichiel Schuurmans <michielschuurmans@gmail.com>2020-10-01 21:40:23 +0200
commita7975976780e2370eade4e041e505273c7d1e2a9 (patch)
tree772abf191aa9f41ec62a336eeae5b38b59504621
parent20600ae10edbfde6a0613c67d5e40438b029578b (diff)
Products: Get single
Signed-off-by: Michiel Schuurmans <michielschuurmans@gmail.com>
-rw-r--r--src/products/app/Http/Controllers/ProductsController.php5
-rw-r--r--src/products/routes/web.php1
2 files changed, 6 insertions, 0 deletions
diff --git a/src/products/app/Http/Controllers/ProductsController.php b/src/products/app/Http/Controllers/ProductsController.php
index 7d55460..58de828 100644
--- a/src/products/app/Http/Controllers/ProductsController.php
+++ b/src/products/app/Http/Controllers/ProductsController.php
@@ -23,6 +23,11 @@ class ProductsController extends Controller
return response()->json($product, 201);
}
+ public function get_one($id)
+ {
+ return response()->json(Product::find($id));
+ }
+
public function delete($id)
{
Product::FindOrFail($id)->delete();
diff --git a/src/products/routes/web.php b/src/products/routes/web.php
index 023939f..28214e1 100644
--- a/src/products/routes/web.php
+++ b/src/products/routes/web.php
@@ -19,6 +19,7 @@ $router->get('/', function () use ($router) {
$router->group(['prefix' => 'api/v1', 'middleware' => 'auth'], function () use ($router) {
$router->get('products', ['middleware' => 'auth:products:read', 'uses' => 'ProductsController@get_all']);
+ $router->get('products/{id}', ['middleware' => 'auth:products:read', 'uses' => 'ProductsController@get_one']);
$router->post('products', ['middleware' => 'auth:products:create', 'uses' => 'ProductsController@create']);
$router->delete('products/{id}', ['middleware' => 'auth:products:delete', 'uses' => 'ProductsController@delete']);
});