Обновлена форма добавления клиента: добавлен переключатель второго контакта
This commit is contained in:
parent
b3e7d17d31
commit
c876701fda
5
app/Modules/CityManager/Config/config.php
Normal file
5
app/Modules/CityManager/Config/config.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
];
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('city_managers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('city_managers');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\CityManager\Http\Controllers;
|
||||
|
||||
use Modules\CityManager\Models\CityManager;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CityManagerController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('cityManager::index');
|
||||
}
|
||||
}
|
||||
11
app/Modules/CityManager/Models/CityManager.php
Normal file
11
app/Modules/CityManager/Models/CityManager.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CityManager\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CityManager extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
68
app/Modules/CityManager/Providers/ModuleServiceProvider.php
Normal file
68
app/Modules/CityManager/Providers/ModuleServiceProvider.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\CityManager\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Livewire\Livewire;
|
||||
|
||||
class ModuleServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected String $moduleName = 'CityManager';
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->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('<name>', \Modules\<NAME>\Http\Livewire\<NAME>::class);
|
||||
}
|
||||
|
||||
protected function registerComponent()
|
||||
{
|
||||
//Blade::component('<name>', \Modules\<NAME>\Http\Components\<NAME>::class);
|
||||
}
|
||||
}
|
||||
24
app/Modules/CityManager/Providers/RouteServiceProvider.php
Normal file
24
app/Modules/CityManager/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\CityManager\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
public function map()
|
||||
{
|
||||
$this->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'));
|
||||
}
|
||||
}
|
||||
13
app/Modules/CityManager/Routes/web.php
Normal file
13
app/Modules/CityManager/Routes/web.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\CityManager\Http\Controllers\CityManagerController;
|
||||
|
||||
Route::middleware(['auth'])->group(function() {
|
||||
|
||||
Route::get('/cityManager', [CityManagerController::class, 'index']);
|
||||
|
||||
Route::middleware(['hasAccess'])->group(function() {
|
||||
/** Routes that need to be protected - Маршруты которые нужно защитить */
|
||||
});
|
||||
});
|
||||
4
app/Modules/CityManager/Views/index.blade.php
Normal file
4
app/Modules/CityManager/Views/index.blade.php
Normal file
@ -0,0 +1,4 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<h1> Example views </h1>
|
||||
@endsection
|
||||
@ -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];
|
||||
|
||||
@ -12,11 +12,13 @@
|
||||
<div class="h4 pb-2 mb-4 fw-bold ">
|
||||
<small>Добавить клиента</small>
|
||||
</div>
|
||||
<ul class="nav nav-tabs">
|
||||
<ul class="nav nav-tabs d-flex align-items-end border-0 pb-0">
|
||||
@foreach ($clients as $clientIndex => $clientItem)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if ($clientIndex == $currentClientIndex) active @else bg-secondary-subtle @endif"
|
||||
<li
|
||||
class="nav-item overflow-hidden @if ($clientIndex == $currentClientIndex) rounded-top border-top border-end border-start bg-light @else m-1 bg-secondary-subtle rounded rouded-5 @endif">
|
||||
<a class="nav-link me-1 border-0 @if ($clientIndex == $currentClientIndex) active text-primary @else p-1 text-dark @endif"
|
||||
aria-current="page" href="#" wire:click="setCurrentClient({{ $clientIndex }})">
|
||||
<i class="bi bi-person-standing"></i>
|
||||
@if (array_key_exists($clientIndex, $clientLabels))
|
||||
{{ $clientLabels[$clientIndex] }}
|
||||
@else
|
||||
@ -26,19 +28,20 @@
|
||||
</li>
|
||||
@endforeach
|
||||
@if ($maxClientsCount > count($clients))
|
||||
<li class="align-middle p-2">
|
||||
<li class="align-middle ps-2 mb-2">
|
||||
<a class="text-light " href="#" wire:click="addClient">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
|
||||
class="bi bi-plus-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16" />
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor"
|
||||
class="bi bi-person-fill-add" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4" />
|
||||
d="M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7m.5-5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0m-2-6a3 3 0 1 1-6 0 3 3 0 0 1 6 0" />
|
||||
<path
|
||||
d="M2 13c0 1 1 1 1 1h5.256A4.5 4.5 0 0 1 8 12.5a4.5 4.5 0 0 1 1.544-3.393Q8.844 9.002 8 9c-5 0-6 3-6 4" />
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
<div class="bg-light border border-1 rounded-bottom-4 mb-2">
|
||||
<div class="bg-light border border-1 rounded-bottom-4 mb-2" style="margin-top:-1px">
|
||||
<div class="p-2">
|
||||
<div class="row mb-2">
|
||||
<div class="col-12 col-xl-6">
|
||||
@ -106,10 +109,18 @@ class="form-control rounded-4 @error('currentClient.phone.{{ $phoneKey }}') is-i
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
@if ($currentClientIndex == 0 && count($clients) <= 2)
|
||||
<div class="form-check form-switch mx-2 my-1">
|
||||
<input class="form-check-input" wire:click="toggleSecondClient" type="checkbox" role="switch"
|
||||
id="switchCheckChecked" @if (count($clients) == 2) checked @endif>
|
||||
<label class="form-check-label" for="switchCheckChecked">Добавить контакт
|
||||
супруга/супруги</label>
|
||||
</div>
|
||||
@endif
|
||||
@if ($currentClientIndex > 0)
|
||||
<div class="mx-3 pb-2 text-end">
|
||||
<a wire:click="deleteCurrentContact" class="text-primary"
|
||||
style="text-decoration: underline dotted;" href="#">
|
||||
<a wire:click="deleteContact" class="text-primary" style="text-decoration: underline dotted;"
|
||||
href="#">
|
||||
Удалить контакт</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user