From bbf324b092e5f6b66512ed3811ed5900f8fde954 Mon Sep 17 00:00:00 2001 From: developer Date: Thu, 23 Apr 2026 15:35:04 +0800 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=83=20=D1=81=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0=D0=BC=D0=B8,=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BF=D0=BE=D0=B8?= =?UTF-8?q?=D1=81=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Livewire/ClientsTable.php | 18 +++++++++ .../Livewire/ClientSearchInputLivewire.php | 38 +++++++++++++++++++ .../Main/Providers/ModuleServiceProvider.php | 1 + .../clients/livewire/search/input.blade.php | 15 ++++++++ ...002_add_full_text_index_to_users_table.php | 27 +++++++++++++ resources/views/clients/table.blade.php | 36 ++++-------------- resources/views/layouts/design.blade.php | 10 +++++ 7 files changed, 116 insertions(+), 29 deletions(-) create mode 100644 app/Modules/Main/Http/Livewire/ClientSearchInputLivewire.php create mode 100644 app/Modules/Main/Views/clients/livewire/search/input.blade.php create mode 100644 app/Modules/User/Database/Migrations/2026_04_23_000002_add_full_text_index_to_users_table.php diff --git a/app/Livewire/ClientsTable.php b/app/Livewire/ClientsTable.php index a48253c..784106c 100644 --- a/app/Livewire/ClientsTable.php +++ b/app/Livewire/ClientsTable.php @@ -6,6 +6,7 @@ use Livewire\WithPagination; use Livewire\WithoutUrlPagination; + use App\Models\User; use Modules\Main\Models\Deal\Client; use Modules\Main\Models\Agent\Agent; @@ -23,14 +24,25 @@ class ClientsTable extends Component public $status; public $count; public $mode;//short || full + private $filter = []; public function mount($status = null, $count = 10, $mode = 'full') { $this->status = $status; $this->count = $count; $this->mode = $mode; + $this->filter = []; } + #[On('clientsTableFilterUpdated')] + public function appendFilter($filter) { + if ($filter) { + $this->filter = $filter; + } else { + $this->filter = []; + } + $this->getClients(); + } #[On('clientCreated')] public function getDeals() { @@ -59,6 +71,9 @@ public function getDeals() { $deals = Deal::where('agent_id', $agent->id); } + if (array_key_exists('status', $this->filter)) { + $deals->where('status', $this->filter['status']); + } if (!$deals) { return Client::where('id',0); } @@ -81,6 +96,9 @@ function getClients() $clients = $clients->select('users.*'); $clients = $clients->orderBy('name'); + if (array_key_exists('search', $this->filter) && $searchString = trim($this->filter['search'])) { + $clients->whereFullText(['name', 'phone', 'email'], $this->filter['search']); + } if ($this->status && $this->status == DealStatus::UNIQUE) { $clients = $clients->whereHas('deals', function ($query) diff --git a/app/Modules/Main/Http/Livewire/ClientSearchInputLivewire.php b/app/Modules/Main/Http/Livewire/ClientSearchInputLivewire.php new file mode 100644 index 0000000..97d2f57 --- /dev/null +++ b/app/Modules/Main/Http/Livewire/ClientSearchInputLivewire.php @@ -0,0 +1,38 @@ +filter) && $this->filter['status'] === $status) { + unset($this->filter['status']); + return; + } + $this->filter['status'] = $status; + } + + public function updated($propertyName) + { + $this->dispatch('clientsTableFilterUpdated', filter: $this->filter); + } + public function render() + { + return view('main::clients.livewire.search.input', [ + 'statuses' => DealStatus::class + ]); + } + + +} \ No newline at end of file diff --git a/app/Modules/Main/Providers/ModuleServiceProvider.php b/app/Modules/Main/Providers/ModuleServiceProvider.php index d3d11c3..6d0e199 100644 --- a/app/Modules/Main/Providers/ModuleServiceProvider.php +++ b/app/Modules/Main/Providers/ModuleServiceProvider.php @@ -78,6 +78,7 @@ protected function registerLivewire() //Livewire::component('', \Modules\\Http\Livewire\::class); Livewire::component('company.agent.create', \Modules\Main\Http\Livewire\CreateAgentLivewire::class); Livewire::component('company.admin.create', \Modules\Main\Http\Livewire\CreateCompanyAdminLivewire::class); + Livewire::component('clients.search.input', \Modules\Main\Http\Livewire\ClientSearchInputLivewire::class); } protected function registerComponent() diff --git a/app/Modules/Main/Views/clients/livewire/search/input.blade.php b/app/Modules/Main/Views/clients/livewire/search/input.blade.php new file mode 100644 index 0000000..20a70c1 --- /dev/null +++ b/app/Modules/Main/Views/clients/livewire/search/input.blade.php @@ -0,0 +1,15 @@ + +
+
+ + + + + +
+ +
\ No newline at end of file diff --git a/app/Modules/User/Database/Migrations/2026_04_23_000002_add_full_text_index_to_users_table.php b/app/Modules/User/Database/Migrations/2026_04_23_000002_add_full_text_index_to_users_table.php new file mode 100644 index 0000000..f5d7b9b --- /dev/null +++ b/app/Modules/User/Database/Migrations/2026_04_23_000002_add_full_text_index_to_users_table.php @@ -0,0 +1,27 @@ +engine = 'MyISAM'; + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + } +}; diff --git a/resources/views/clients/table.blade.php b/resources/views/clients/table.blade.php index 0451e96..228143b 100644 --- a/resources/views/clients/table.blade.php +++ b/resources/views/clients/table.blade.php @@ -3,26 +3,14 @@ @extends('layouts.app') @section('content')
-
-
- - - - - - - - +
+
+ @livewire('clients.search.input')
-
@@ -32,20 +20,10 @@
- - @if (!$status || $status == 'all' || $status == 'unique') -

Уникальные

-
- @livewire('clientsTable', ['status' => 'UNIQUE']) +
+
+ @livewire('clientsTable')
- @endif - - @if (!$status || $status == 'all' || $status == 'not unique') -

Не уникальные

-
- @livewire('clientsTable', ['status' => 'NOT UNIQUE']) -
- @endif
diff --git a/resources/views/layouts/design.blade.php b/resources/views/layouts/design.blade.php index 450c628..32e7b48 100644 --- a/resources/views/layouts/design.blade.php +++ b/resources/views/layouts/design.blade.php @@ -30,6 +30,7 @@ } .bg-primary { + color:#fff; background-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important; @@ -51,6 +52,7 @@ } .btn-primary { + color:#aaaaaa; background-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important; @@ -59,6 +61,14 @@ !important; } + .btn:hover { + + } + + .btn-primary:hover { + color:#fff; + } + input[type="radio"]:checked+label { background-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important; border-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important;