From c876701fda03a28b18cc49156ee92a6303265eb5 Mon Sep 17 00:00:00 2001 From: Thekindbull Date: Tue, 16 Sep 2025 12:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=D0=B0:=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=20=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Modules/CityManager/Config/config.php | 5 ++ ...9_16_015544_create_city_managers_table.php | 27 ++++++++ .../Controllers/CityManagerController.php | 17 +++++ .../CityManager/Models/CityManager.php | 11 +++ .../Providers/ModuleServiceProvider.php | 68 +++++++++++++++++++ .../Providers/RouteServiceProvider.php | 24 +++++++ app/Modules/CityManager/Routes/web.php | 13 ++++ app/Modules/CityManager/Views/index.blade.php | 4 ++ .../Http/Livewire/ClientCreateLivewire.php | 26 +++++-- .../Views/livewire/form.blade.php | 33 ++++++--- 10 files changed, 213 insertions(+), 15 deletions(-) create mode 100644 app/Modules/CityManager/Config/config.php create mode 100644 app/Modules/CityManager/Database/Migrations/2025_09_16_015544_create_city_managers_table.php create mode 100644 app/Modules/CityManager/Http/Controllers/CityManagerController.php create mode 100644 app/Modules/CityManager/Models/CityManager.php create mode 100644 app/Modules/CityManager/Providers/ModuleServiceProvider.php create mode 100644 app/Modules/CityManager/Providers/RouteServiceProvider.php create mode 100644 app/Modules/CityManager/Routes/web.php create mode 100644 app/Modules/CityManager/Views/index.blade.php diff --git a/app/Modules/CityManager/Config/config.php b/app/Modules/CityManager/Config/config.php new file mode 100644 index 0000000..ce09543 --- /dev/null +++ b/app/Modules/CityManager/Config/config.php @@ -0,0 +1,5 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('city_managers'); + } +}; diff --git a/app/Modules/CityManager/Http/Controllers/CityManagerController.php b/app/Modules/CityManager/Http/Controllers/CityManagerController.php new file mode 100644 index 0000000..ecd2e6f --- /dev/null +++ b/app/Modules/CityManager/Http/Controllers/CityManagerController.php @@ -0,0 +1,17 @@ +app->register(RouteServiceProvider::class); + } + + public function boot() + { + $this->registerViews(); + $this->registerLivewireViews(); + $this->registerMigrations(); + $this->registerConfig(); + $this->registerComponent(); + $this->registerLivewire(); + } + + protected function registerViews() + { + $moduleViewsPath = __DIR__.'/../Views'; + $this->loadViewsFrom( + $moduleViewsPath, strtolower($this->moduleName) + ); + } + + protected function registerLivewireViews() + { + $moduleViewsPath = __DIR__.'/../Views/livewire'; + $this->loadViewsFrom( + $moduleViewsPath, strtolower($this->moduleName) + ); + } + + protected function registerMigrations() + { + $this->loadMigrationsFrom( + app_path('Modules/'.$this->moduleName.'/Database/Migrations') + ); + } + + protected function registerConfig() + { + $path = app_path('Modules/'.$this->moduleName.'/Config/config.php'); + $this->mergeConfigFrom( + $path, strtolower($this->moduleName) + ); + } + + protected function registerLivewire() + { + //Livewire::component('', \Modules\\Http\Livewire\::class); + } + + protected function registerComponent() + { + //Blade::component('', \Modules\\Http\Components\::class); + } +} \ No newline at end of file diff --git a/app/Modules/CityManager/Providers/RouteServiceProvider.php b/app/Modules/CityManager/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..09ff2f2 --- /dev/null +++ b/app/Modules/CityManager/Providers/RouteServiceProvider.php @@ -0,0 +1,24 @@ +registerWebRoutes(); + } + + protected function registerWebRoutes() + { + //Add Web Routes with web Guard + Route::middleware('web') + //Set Default Controllers Namespace + ->namespace('Modules\\CityManager\\Http\\Controllers') + ->group(app_path('Modules/CityManager/Routes/web.php')); + } +} \ No newline at end of file diff --git a/app/Modules/CityManager/Routes/web.php b/app/Modules/CityManager/Routes/web.php new file mode 100644 index 0000000..6548b73 --- /dev/null +++ b/app/Modules/CityManager/Routes/web.php @@ -0,0 +1,13 @@ +group(function() { + + Route::get('/cityManager', [CityManagerController::class, 'index']); + + Route::middleware(['hasAccess'])->group(function() { + /** Routes that need to be protected - Маршруты которые нужно защитить */ + }); +}); \ No newline at end of file diff --git a/app/Modules/CityManager/Views/index.blade.php b/app/Modules/CityManager/Views/index.blade.php new file mode 100644 index 0000000..f8198cf --- /dev/null +++ b/app/Modules/CityManager/Views/index.blade.php @@ -0,0 +1,4 @@ +@extends('layouts.app') + @section('content') +

Example views

+ @endsection \ No newline at end of file diff --git a/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php b/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php index 79ca4ec..3ddd46e 100644 --- a/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php +++ b/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php @@ -59,13 +59,17 @@ public function addClient() } $this->setCurrentClient(count($this->clients) - 1); } - public function deleteCurrentContact() + public function deleteContact($index = false) { - if ($this->currentClientIndex > 0) + if ($index === false) { - unset($this->clients[$this->currentClientIndex]); + $index = $this->currentClientIndex; + } + if ($index > 0) + { + unset($this->clients[$index]); $this->clients = array_values($this->clients); - $this->updateCurrentClientIndex($this->currentClientIndex - 1); + $this->updateCurrentClientIndex($index - 1); } } public function setCurrentClient($index) @@ -73,6 +77,20 @@ public function setCurrentClient($index) $this->saveClient(); $this->updateCurrentClientIndex($index); } + public function toggleSecondClient() + { + if ($this->currentClientIndex == 0) + { + if (count($this->clients) == 2) + { + $this->deleteContact(1); + } + elseif (count($this->clients) == 1) + { + $this->addClient(); + } + } + } private function updateCurrentClientIndex($index) { $this->currentClient = $this->clients[$index]; diff --git a/app/Modules/ClientCreateForm/Views/livewire/form.blade.php b/app/Modules/ClientCreateForm/Views/livewire/form.blade.php index 9150d01..7df5339 100644 --- a/app/Modules/ClientCreateForm/Views/livewire/form.blade.php +++ b/app/Modules/ClientCreateForm/Views/livewire/form.blade.php @@ -12,11 +12,13 @@
Добавить клиента
-