Skip to content

Commit 3da1afa

Browse files
Merge pull request #2320 from suraj-webkul/issue#2300
Issue #2300 has been fixed.
2 parents 623c84c + 6e1b01d commit 3da1afa

File tree

20 files changed

+552
-198
lines changed

20 files changed

+552
-198
lines changed

packages/Webkul/Admin/src/Http/Controllers/Configuration/ConfigurationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function download()
6868
}
6969

7070
/**
71-
* Display a listing of the resource.
71+
* Search for configurations.
7272
*/
7373
public function search(): JsonResponse
7474
{

packages/Webkul/Admin/src/Http/Controllers/Settings/SettingController.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Webkul\Admin\Http\Controllers\Settings;
44

5+
use Illuminate\Http\JsonResponse;
6+
use Illuminate\Support\Collection;
57
use Webkul\Admin\Http\Controllers\Controller;
8+
use Webkul\Core\Menu\MenuItem;
69

710
class SettingController extends Controller
811
{
@@ -15,4 +18,80 @@ public function index()
1518
{
1619
return view('admin::settings.index');
1720
}
21+
22+
/**
23+
* Search for settings.
24+
*/
25+
public function search(): ?JsonResponse
26+
{
27+
$query = strtolower(request()->query('query'));
28+
29+
if (empty($query)) {
30+
return response()->json(['data' => []]);
31+
}
32+
33+
$results = $this->searchMenuItems($this->getSettingsConfig(), $query);
34+
35+
return response()->json([
36+
'data' => $results->values(),
37+
]);
38+
}
39+
40+
/**
41+
* Recursively search through menu items and children.
42+
*
43+
* @param Collection<int, MenuItem> $menuItems
44+
* @return Collection<int, array<string, mixed>>
45+
*/
46+
protected function searchMenuItems(Collection $menuItems, string $query): Collection
47+
{
48+
$results = collect();
49+
50+
foreach ($menuItems as $item) {
51+
if ($this->matchesQuery($item, $query)) {
52+
$results->push([
53+
'name' => $item->getName(),
54+
'url' => $item->getUrl(),
55+
'icon' => $item->getIcon(),
56+
'key' => $item->getKey(),
57+
]);
58+
}
59+
60+
if ($item->haveChildren()) {
61+
$childResults = $this->searchMenuItems($item->getChildren(), $query);
62+
63+
$results = $results->merge($childResults);
64+
}
65+
}
66+
67+
return $results;
68+
}
69+
70+
/**
71+
* Determine if the menu item matches the query.
72+
*/
73+
protected function matchesQuery(MenuItem $item, string $query): bool
74+
{
75+
$query = strtolower($query);
76+
$url = strtolower($item->getUrl());
77+
78+
if (
79+
! $url
80+
|| ! str_contains($url, $query)
81+
) {
82+
return false;
83+
}
84+
85+
return true;
86+
}
87+
88+
/**
89+
* Get the settings configuration.
90+
*/
91+
protected function getSettingsConfig(): Collection
92+
{
93+
return menu()
94+
->getItems('admin')
95+
->filter(fn (MenuItem $item) => $item->getKey() === 'settings');
96+
}
1897
}

packages/Webkul/Admin/src/Resources/lang/ar/app.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,27 @@
368368
'layouts' => [
369369
'header' => [
370370
'mega-search' => [
371-
'title' => 'البحث الشامل',
371+
'title' => 'البحث الشامل',
372372

373373
'tabs' => [
374-
'leads' => 'العملاء المحتملين',
375-
'quotes' => 'عروض الأسعار',
376-
'persons' => 'الأشخاص',
377-
'products' => 'المنتجات',
374+
'leads' => 'العملاء المتوقعين',
375+
'quotes' => 'عروض الأسعار',
376+
'persons' => 'الأشخاص',
377+
'products' => 'المنتجات',
378+
'settings' => 'الإعدادات',
379+
'configurations' => 'التهيئة',
378380
],
379381

380-
'explore-all-products' => 'استكشاف جميع المنتجات',
381-
'explore-all-leads' => 'استكشاف جميع العملاء المحتملين',
382-
'explore-all-contacts' => 'استكشاف جميع جهات الاتصال',
383-
'explore-all-quotes' => 'استكشاف جميع عروض الأسعار',
384-
'explore-all-matching-products' => 'استكشاف جميع المنتجات المطابقة لـ ":query" (:count)',
385-
'explore-all-matching-leads' => 'استكشاف جميع العملاء المحتملين المطابقين لـ ":query" (:count)',
386-
'explore-all-matching-contacts' => 'استكشاف جميع جهات الاتصال المطابقة لـ ":query" (:count)',
387-
'explore-all-matching-quotes' => 'استكشاف جميع عروض الأسعار المطابقة لـ ":query" (:count)',
382+
'explore-all-products' => 'استعرض جميع المنتجات',
383+
'explore-all-leads' => 'استعرض جميع العملاء المتوقعين',
384+
'explore-all-contacts' => 'استعرض جميع الأشخاص',
385+
'explore-all-quotes' => 'استعرض جميع عروض الأسعار',
386+
'explore-all-settings' => 'استعرض جميع الإعدادات',
387+
'explore-all-configurations' => 'استعرض جميع التهيئات',
388+
'explore-all-matching-products' => 'استعرض جميع المنتجات المطابقة لـ ":query" (:count)',
389+
'explore-all-matching-leads' => 'استعرض جميع العملاء المتوقعين المطابقين لـ ":query" (:count)',
390+
'explore-all-matching-contacts' => 'استعرض جميع الأشخاص المطابقين لـ ":query" (:count)',
391+
'explore-all-matching-quotes' => 'استعرض جميع عروض الأسعار المطابقة لـ ":query" (:count)',
388392
],
389393
],
390394
],

packages/Webkul/Admin/src/Resources/lang/en/app.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,20 @@
375375
'title' => 'Mega Search',
376376

377377
'tabs' => [
378-
'leads' => 'Leads',
379-
'quotes' => 'Quotes',
380-
'persons' => 'Persons',
381-
'products' => 'Products',
378+
'leads' => 'Leads',
379+
'quotes' => 'Quotes',
380+
'persons' => 'Persons',
381+
'products' => 'Products',
382+
'settings' => 'Settings',
383+
'configurations' => 'Configurations',
382384
],
383385

384386
'explore-all-products' => 'Explore all Products',
385387
'explore-all-leads' => 'Explore all Leads',
386388
'explore-all-contacts' => 'Explore all Contacts',
387389
'explore-all-quotes' => 'Explore all Quotes',
390+
'explore-all-settings' => 'Explore all Settings',
391+
'explore-all-configurations' => 'Explore all Configurations',
388392
'explore-all-matching-products' => 'Explore all products matching ":query" (:count)',
389393
'explore-all-matching-leads' => 'Explore all leads matching ":query" (:count)',
390394
'explore-all-matching-contacts' => 'Explore all contacts matching ":query" (:count)',

packages/Webkul/Admin/src/Resources/lang/es/app.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,22 +374,26 @@
374374

375375
'header' => [
376376
'mega-search' => [
377-
'title' => 'Búsqueda Mega',
377+
'title' => 'Búsqueda Avanzada',
378378

379379
'tabs' => [
380-
'leads' => 'Oportunidades',
381-
'quotes' => 'Cotizaciones',
382-
'persons' => 'Personas',
383-
'products' => 'Productos',
380+
'leads' => 'Clientes Potenciales',
381+
'quotes' => 'Cotizaciones',
382+
'persons' => 'Personas',
383+
'products' => 'Productos',
384+
'settings' => 'Configuraciones',
385+
'configurations' => 'Ajustes',
384386
],
385387

386-
'explore-all-products' => 'Explorar todos los Productos',
387-
'explore-all-leads' => 'Explorar todas las Oportunidades',
388-
'explore-all-contacts' => 'Explorar todos los Contactos',
389-
'explore-all-quotes' => 'Explorar todas las Cotizaciones',
388+
'explore-all-products' => 'Explorar todos los productos',
389+
'explore-all-leads' => 'Explorar todos los clientes potenciales',
390+
'explore-all-contacts' => 'Explorar todas las personas',
391+
'explore-all-quotes' => 'Explorar todas las cotizaciones',
392+
'explore-all-settings' => 'Explorar todas las configuraciones',
393+
'explore-all-configurations' => 'Explorar todos los ajustes',
390394
'explore-all-matching-products' => 'Explorar todos los productos que coinciden con ":query" (:count)',
391-
'explore-all-matching-leads' => 'Explorar todas las oportunidades que coinciden con ":query" (:count)',
392-
'explore-all-matching-contacts' => 'Explorar todos los contactos que coinciden con ":query" (:count)',
395+
'explore-all-matching-leads' => 'Explorar todos los clientes potenciales que coinciden con ":query" (:count)',
396+
'explore-all-matching-contacts' => 'Explorar todas las personas que coinciden con ":query" (:count)',
393397
'explore-all-matching-quotes' => 'Explorar todas las cotizaciones que coinciden con ":query" (:count)',
394398
],
395399
],

packages/Webkul/Admin/src/Resources/lang/fa/app.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -375,23 +375,27 @@
375375

376376
'header' => [
377377
'mega-search' => [
378-
'title' => 'جستجوی بزرگ',
378+
'title' => 'جستجوی پیشرفته',
379379

380380
'tabs' => [
381-
'leads' => 'سرنخ‌ها',
382-
'quotes' => 'پیشنهادات',
383-
'persons' => 'افراد',
384-
'products' => 'محصولات',
381+
'leads' => 'سرنخ‌ها',
382+
'quotes' => 'پیش‌فاکتورها',
383+
'persons' => 'افراد',
384+
'products' => 'محصولات',
385+
'settings' => 'تنظیمات',
386+
'configurations' => 'پیکربندی‌ها',
385387
],
386388

387-
'explore-all-products' => 'کاوش در تمامی محصولات',
388-
'explore-all-leads' => 'کاوش در تمامی سرنخ‌ها',
389-
'explore-all-contacts' => 'کاوش در تمامی مخاطبین',
390-
'explore-all-quotes' => 'کاوش در تمامی پیشنهادات',
391-
'explore-all-matching-products' => 'کاوش در تمامی محصولات مطابق ":query" (:count)',
392-
'explore-all-matching-leads' => 'کاوش در تمامی سرنخ‌های مطابق ":query" (:count)',
393-
'explore-all-matching-contacts' => 'کاوش در تمامی مخاطبین مطابق ":query" (:count)',
394-
'explore-all-matching-quotes' => 'کاوش در تمامی پیشنهادات مطابق ":query" (:count)',
389+
'explore-all-products' => 'مشاهده همه محصولات',
390+
'explore-all-leads' => 'مشاهده همه سرنخ‌ها',
391+
'explore-all-contacts' => 'مشاهده همه افراد',
392+
'explore-all-quotes' => 'مشاهده همه پیش‌فاکتورها',
393+
'explore-all-settings' => 'مشاهده همه تنظیمات',
394+
'explore-all-configurations' => 'مشاهده همه پیکربندی‌ها',
395+
'explore-all-matching-products' => 'مشاهده همه محصولات مطابق با ":query" (:count)',
396+
'explore-all-matching-leads' => 'مشاهده همه سرنخ‌ها مطابق با ":query" (:count)',
397+
'explore-all-matching-contacts' => 'مشاهده همه افراد مطابق با ":query" (:count)',
398+
'explore-all-matching-quotes' => 'مشاهده همه پیش‌فاکتورها مطابق با ":query" (:count)',
395399
],
396400
],
397401
],

packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,27 @@
368368

369369
'header' => [
370370
'mega-search' => [
371-
'title' => 'Busca rápida',
371+
'title' => 'Busca Avançada',
372372

373373
'tabs' => [
374-
'leads' => 'Oportunidades',
375-
'quotes' => 'Cotações',
376-
'persons' => 'Pessoas',
377-
'products' => 'Produtos',
374+
'leads' => 'Leads',
375+
'quotes' => 'Cotações',
376+
'persons' => 'Pessoas',
377+
'products' => 'Produtos',
378+
'settings' => 'Configurações',
379+
'configurations' => 'Configurações Avançadas',
378380
],
379381

380-
'explore-all-products' => 'Explorar todos os Produtos',
381-
'explore-all-leads' => 'Explorar todos as Oportunidades',
382-
'explore-all-contacts' => 'Explorar todos os Contatos',
383-
'explore-all-quotes' => 'Explorar todas as Cotações',
384-
'explore-all-matching-products' => 'Explorar todos os produtos correspondentes a ":query" (:count)',
385-
'explore-all-matching-leads' => 'Explorar todos os negócios correspondentes a ":query" (:count)',
386-
'explore-all-matching-contacts' => 'Explorar todos os contatos correspondentes a ":query" (:count)',
387-
'explore-all-matching-quotes' => 'Explorar todas as cotações correspondentes a ":query" (:count)',
382+
'explore-all-products' => 'Explorar todos os produtos',
383+
'explore-all-leads' => 'Explorar todos os leads',
384+
'explore-all-contacts' => 'Explorar todas as pessoas',
385+
'explore-all-quotes' => 'Explorar todas as cotações',
386+
'explore-all-settings' => 'Explorar todas as configurações',
387+
'explore-all-configurations' => 'Explorar todas as configurações avançadas',
388+
'explore-all-matching-products' => 'Explorar todos os produtos que correspondem a ":query" (:count)',
389+
'explore-all-matching-leads' => 'Explorar todos os leads que correspondem a ":query" (:count)',
390+
'explore-all-matching-contacts' => 'Explorar todas as pessoas que correspondem a ":query" (:count)',
391+
'explore-all-matching-quotes' => 'Explorar todas as cotações que correspondem a ":query" (:count)',
388392
],
389393
],
390394
],

packages/Webkul/Admin/src/Resources/lang/tr/app.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,23 +374,27 @@
374374

375375
'header' => [
376376
'mega-search' => [
377-
'title' => 'Mega Arama',
377+
'title' => 'Gelişmiş Arama',
378378

379379
'tabs' => [
380-
'leads' => 'Müşteriler',
381-
'quotes' => 'Teklifler',
382-
'persons' => 'Kişiler',
383-
'products' => 'Ürünler',
380+
'leads' => 'Potansiyel Müşteriler',
381+
'quotes' => 'Teklifler',
382+
'persons' => 'Kişiler',
383+
'products' => 'Ürünler',
384+
'settings' => 'Ayarlar',
385+
'configurations' => 'Yapılandırmalar',
384386
],
385387

386-
'explore-all-products' => 'Tüm Ürünleri Keşfet',
387-
'explore-all-leads' => 'Tüm Müşterileri Keşfet',
388-
'explore-all-contacts' => 'Tüm İletişimleri Keşfet',
389-
'explore-all-quotes' => 'Tüm Teklifleri Keşfet',
390-
'explore-all-matching-products' => '":query" (:count) ile eşleşen tüm ürünleri keşfet',
391-
'explore-all-matching-leads' => '":query" (:count) ile eşleşen tüm müşterileri keşfet',
392-
'explore-all-matching-contacts' => '":query" (:count) ile eşleşen tüm iletişimleri keşfet',
393-
'explore-all-matching-quotes' => '":query" (:count) ile eşleşen tüm teklifleri keşfet',
388+
'explore-all-products' => 'Tüm ürünleri keşfet',
389+
'explore-all-leads' => 'Tüm potansiyel müşterileri keşfet',
390+
'explore-all-contacts' => 'Tüm kişileri keşfet',
391+
'explore-all-quotes' => 'Tüm teklifleri keşfet',
392+
'explore-all-settings' => 'Tüm ayarları keşfet',
393+
'explore-all-configurations' => 'Tüm yapılandırmaları keşfet',
394+
'explore-all-matching-products' => '":query" ile eşleşen tüm ürünleri keşfet (:count)',
395+
'explore-all-matching-leads' => '":query" ile eşleşen tüm potansiyel müşterileri keşfet (:count)',
396+
'explore-all-matching-contacts' => '":query" ile eşleşen tüm kişileri keşfet (:count)',
397+
'explore-all-matching-quotes' => '":query" ile eşleşen tüm teklifleri keşfet (:count)',
394398
],
395399
],
396400
],

0 commit comments

Comments
 (0)