From bff1cb798f02bd42c7ce6dc4367cdbe17074448c Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Fri, 8 Nov 2024 14:48:52 +0300 Subject: [PATCH] action install to ms --- .../controllers/ModuleShopRestController.php | 16 ++++++++++++++++ app/modules/module_shop/routs/ms.php | 1 + 2 files changed, 17 insertions(+) diff --git a/app/modules/module_shop/controllers/ModuleShopRestController.php b/app/modules/module_shop/controllers/ModuleShopRestController.php index e9ab3d8..613decd 100644 --- a/app/modules/module_shop/controllers/ModuleShopRestController.php +++ b/app/modules/module_shop/controllers/ModuleShopRestController.php @@ -97,4 +97,20 @@ class ModuleShopRestController extends RestController $this->renderApi($res); } + public function actionInstall(int $id): void + { + $model = $this->model->where("id", $id)->first(); + + header('Content-type: application/zip'); + header('Content-Disposition: attachment; filename="' . $model->slug . '.igm"'); + header('Content-Length: ' . filesize(ROOT_DIR . $model->path_to_archive)); + +// Debug::dd(filesize(ROOT_DIR . $model->path_to_archive)); + readfile(ROOT_DIR . $model->path_to_archive); + + + $model->installations++; + $model->save(); + } + } \ No newline at end of file diff --git a/app/modules/module_shop/routs/ms.php b/app/modules/module_shop/routs/ms.php index 1b16002..1d28a30 100644 --- a/app/modules/module_shop/routs/ms.php +++ b/app/modules/module_shop/routs/ms.php @@ -23,6 +23,7 @@ App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){ App::$collector->group(['before' => 'bearer'], function (CgRouteCollector $router){ App::$collector->group(["prefix" => "module_shop"], function (CgRouteCollector $router){ App::$collector->get('/gb_slug', [\app\modules\module_shop\controllers\ModuleShopRestController::class, 'actionIndexGroupBySlug']); + App::$collector->get('/install/{id}', [\app\modules\module_shop\controllers\ModuleShopRestController::class, 'actionInstall']); }); $router->rest("module_shop", [\app\modules\module_shop\controllers\ModuleShopRestController::class]); });