diff --git a/app/modules/card/CardModule.php b/app/modules/card/CardModule.php
new file mode 100644
index 0000000..9d2d86e
--- /dev/null
+++ b/app/modules/card/CardModule.php
@@ -0,0 +1,8 @@
+paymentType(2)->bank(323, 42, 75)->client(15);
+
+ return CardNumber::generate($customer, $formatter);
+ }
+
+}
\ No newline at end of file
diff --git a/app/modules/card/manifest.json b/app/modules/card/manifest.json
new file mode 100644
index 0000000..eaaf81e
--- /dev/null
+++ b/app/modules/card/manifest.json
@@ -0,0 +1,11 @@
+{
+ "name": "Card",
+ "version": "0.1",
+ "author": "ITGuild",
+ "slug": "card",
+ "description": "Card module",
+ "module_class": "app\\modules\\card\\CardModule",
+ "module_class_file": "{APP}/modules/card/CardModule.php",
+ "routs": "routs/card.php",
+ "migration_path": "migrations"
+}
\ No newline at end of file
diff --git a/app/modules/card/routs/card.php b/app/modules/card/routs/card.php
new file mode 100644
index 0000000..cd5f47e
--- /dev/null
+++ b/app/modules/card/routs/card.php
@@ -0,0 +1,15 @@
+group(["prefix" => "admin"], function (CgRouteCollector $router) {
+ App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
+ App::$collector->group(["prefix" => "card"], function (CGRouteCollector $router) {
+// App::$collector->get('/test', [\app\modules\card\controllers\CardController::class, 'actionTestCard']);
+ });
+ });
+});
\ No newline at end of file
diff --git a/app/modules/tgbot/TgbotModule.php b/app/modules/tgbot/TgbotModule.php
new file mode 100644
index 0000000..d9f814b
--- /dev/null
+++ b/app/modules/tgbot/TgbotModule.php
@@ -0,0 +1,12 @@
+beginForm(isset($model) ? "/admin/tg-bot/edit/" . $model->id : "/admin/tg-bot");
+
+$form->field(class: \itguild\forms\inputs\TextInput::class, name: "bot_id", params: [
+ 'class' => "form-control",
+ 'placeholder' => 'Bot ID',
+ 'value' => $model->bot_id ?? ''
+])
+ ->setLabel("Bot ID")
+ ->render();
+
+$form->field(class: \itguild\forms\inputs\TextInput::class, name: "dialog_id", params: [
+ 'class' => "form-control",
+ 'placeholder' => 'Dialog ID',
+ 'value' => $model->dialog_id ?? ''
+])
+ ->setLabel("Dialog ID")
+ ->render();
+
+$form->field(class: \itguild\forms\inputs\TextInput::class, name: "username", params: [
+ 'class' => "form-control",
+ 'placeholder' => 'Username',
+ 'value' => $model->username ?? ''
+])
+ ->setLabel("Username")
+ ->render();
+
+$form->field(class: \itguild\forms\inputs\TextInput::class, name: "first_name", params: [
+ 'class' => "form-control",
+ 'placeholder' => 'First name',
+ 'value' => $model->first_name ?? ''
+])
+ ->setLabel("First name")
+ ->render();
+
+$form->field(class: \itguild\forms\inputs\TextInput::class, name: "last_name", params: [
+ 'class' => "form-control",
+ 'placeholder' => 'Last name',
+ 'value' => $model->last_name ?? ''
+])
+ ->setLabel("Last name")
+ ->render();
+
+
+$form->field(\itguild\forms\inputs\Select::class, 'status', [
+ 'class' => "form-control",
+ 'value' => $model->status ?? ''
+])
+ ->setLabel("Статус")
+ ->setOptions(Tgbot::getStatus())
+ ->render();
+?>
+
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
+ 'class' => "btn btn-primary ",
+ 'value' => 'Отправить',
+ 'typeInput' => 'submit'
+ ])
+ ->render();
+ ?>
+
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
+ 'class' => "btn btn-warning",
+ 'value' => 'Сбросить',
+ 'typeInput' => 'reset'
+ ])
+ ->render();
+ ?>
+
+
+endForm();
diff --git a/app/modules/tgbot/views/tgbot/index.php b/app/modules/tgbot/views/tgbot/index.php
new file mode 100644
index 0000000..c1c59a0
--- /dev/null
+++ b/app/modules/tgbot/views/tgbot/index.php
@@ -0,0 +1,41 @@
+setTitle("Список существующих диалогов");
+
+$table = new ListEloquentTable(new EloquentDataProvider(\app\modules\tgbot\models\Tgbot::class, [
+ 'currentPage' => $page_number,
+ 'perPage' => 8,
+ 'params' => ["class" => "table table-bordered", "border" => "2"],
+ 'baseUrl' => "/admin/tg-bot",
+]));
+
+$table->beforePrint(function () {
+ return PrimaryBtn::create("Создать", "/admin/tg-bot/create")->fetch();
+});
+
+$table->columns([
+ "status" => [
+ "value" => function ($cell) {
+ return \app\modules\tgbot\models\Tgbot::getStatus()[$cell];
+ }]
+]);
+
+
+$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
+$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class);
+$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class);
+$table->create();
+$table->render();
\ No newline at end of file
diff --git a/app/modules/tgbot/views/tgbot/view.php b/app/modules/tgbot/views/tgbot/view.php
new file mode 100644
index 0000000..1fcbda1
--- /dev/null
+++ b/app/modules/tgbot/views/tgbot/view.php
@@ -0,0 +1,30 @@
+ ["class" => "table table-bordered", "border" => "2"],
+ 'baseUrl' => "/admin/tg-bot",
+]));
+$table->beforePrint(function () use ($tg) {
+ $btn = PrimaryBtn::create("Список", "/admin/tg-bot")->fetch();
+ $btn .= SuccessBtn::create("Редактировать", "/admin/tg-bot/update/" . $tg->id)->fetch();
+ $btn .= DangerBtn::create("Удалить", "/admin/tg-bot/delete/" . $tg->id)->fetch();
+ return $btn;
+});
+$table->rows([
+ 'status' => (function ($data) {
+ return \app\modules\tgbot\models\Tgbot::getStatus()[$data];
+ })
+]);
+$table->create();
+$table->render();
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 84a938a..37d7975 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,10 @@
"guzzlehttp/guzzle": "^7.9",
"phpmailer/phpmailer": "^6.9",
"zircote/swagger-php": "^4.11",
- "doctrine/annotations": "^2.0"
+ "doctrine/annotations": "^2.0",
+ "ext-gd": "*",
+ "dragon-code/card-number": "^1.6",
+ "endroid/qr-code": "^6.0"
},
"autoload": {
"psr-4": {
diff --git a/kernel/FileUpload.php b/kernel/FileUpload.php
index 7a1705b..a61893c 100644
--- a/kernel/FileUpload.php
+++ b/kernel/FileUpload.php
@@ -36,7 +36,9 @@ class FileUpload
$newFileName = md5(time() . $this->fileName) . '.' . $this->fileExtension;
if (in_array($this->fileExtension, $this->allowedFileExtensions)) {
$this->uploadDir = $uploadDir . mb_substr($newFileName, 0, 2) . '/' . mb_substr($newFileName, 2, 2) . '/';
- mkdir(ROOT_DIR . $this->uploadDir, 0777, true);
+ $oldMask = umask(0);
+ mkdir(ROOT_DIR . $this->uploadDir, 0775, true);
+ umask($oldMask);
$uploadFileDir = ROOT_DIR . $this->uploadDir;
$this->destPath = $uploadFileDir . $newFileName;
$this->uploadFile = $this->uploadDir . $newFileName;
@@ -49,7 +51,9 @@ class FileUpload
} else {
if (in_array($this->fileExtension, $this->allowedFileExtensions)) {
$this->uploadDir = $uploadDir;
- mkdir(ROOT_DIR . $this->uploadDir, 0777, true);
+ $oldMask = umask(0);
+ mkdir(ROOT_DIR . $this->uploadDir, 0775, true);
+ umask($oldMask);
$uploadFileDir = ROOT_DIR . $this->uploadDir;
$this->destPath = $uploadFileDir . $this->fileName;
$this->uploadFile = $this->uploadDir . $this->fileName;
diff --git a/kernel/RestController.php b/kernel/RestController.php
index 2d7596d..99ba279 100644
--- a/kernel/RestController.php
+++ b/kernel/RestController.php
@@ -17,13 +17,32 @@ class RestController
return [];
}
+ protected function filters(): array
+ {
+ return [];
+ }
+
#[NoReturn] public function actionIndex(): void
{
$request = new Request();
+ $get = $request->get();
$page = $request->get('page') ?? 1;
$perPage = $request->get('per_page') ?? 10;
$query = $this->model->query();
+ if ($this->filters()) {
+ foreach ($this->filters() as $filter){
+ if (key_exists($filter, $get)){
+ if (is_numeric($get[$filter])){
+ $query->where($filter, $get[$filter]);
+ }
+ elseif (is_string($get[$filter])){
+ $query->where($filter,'like', '%' . $get[$filter] . '%');
+ }
+ }
+ }
+ }
+
if ($page > 1) {
$query->skip(($page - 1) * $perPage)->take($perPage);
} else {
@@ -31,7 +50,7 @@ class RestController
}
$expand = $this->expand();
- $expandParams = explode( ",", $request->get('expand') ?? "");
+ $expandParams = explode(",", $request->get('expand') ?? "");
$finalExpand = array_intersect($expandParams, $expand);
if ($finalExpand) {
$res = $query->get()->load($finalExpand)->toArray();
@@ -46,14 +65,14 @@ class RestController
{
$expand = $this->expand();
$request = new Request();
- $expandParams = explode( ",", $request->get('expand') ?? "");
+ $expandParams = explode(",", $request->get('expand') ?? "");
$model = $this->model->where("id", $id)->first();
$finalExpand = array_intersect($expandParams, $expand);
- if ($finalExpand){
+ if ($finalExpand) {
$model->load($finalExpand);
}
$res = [];
- if ($model){
+ if ($model) {
$res = $model->toArray();
}
@@ -64,7 +83,7 @@ class RestController
{
$model = $this->model->where("id", $id)->first();
$res = [];
- if ($model){
+ if ($model) {
$res = $model->toArray();
}
@@ -78,7 +97,7 @@ class RestController
{
$request = new Request();
$data = $request->post();
- foreach ($this->model->getFillable() as $item){
+ foreach ($this->model->getFillable() as $item) {
$this->model->{$item} = $data[$item] ?? null;
}
$this->model->save();
@@ -93,8 +112,8 @@ class RestController
$model = $this->model->where('id', $id)->first();
- foreach ($model->getFillable() as $item){
- if (!empty($data[$item])){
+ foreach ($model->getFillable() as $item) {
+ if (!empty($data[$item])) {
$model->{$item} = $data[$item] ?? null;
}
}
@@ -117,5 +136,4 @@ class RestController
}
-
}
\ No newline at end of file
diff --git a/kernel/admin_themes/default/layout/main.php b/kernel/admin_themes/default/layout/main.php
index db00106..98be7fb 100644
--- a/kernel/admin_themes/default/layout/main.php
+++ b/kernel/admin_themes/default/layout/main.php
@@ -26,10 +26,13 @@