From d5b518524cfb2ca5e18a32e588532f6a5052840d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 20 Sep 2023 22:05:02 +1000 Subject: [PATCH 1/2] Updates for search --- app/Http/Controllers/SearchController.php | 79 +++++++++++++---------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 8e7559894b1e..1b89d9b37853 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -11,14 +11,15 @@ namespace App\Http\Controllers; -use App\Models\User; +use App\Http\Requests\Search\GenericSearchRequest; use App\Models\Client; use App\Models\ClientContact; use App\Models\Invoice; +use App\Models\User; class SearchController extends Controller { - public function __invoke() + public function __invoke(GenericSearchRequest $request) { /** @var \App\Models\User $user */ $user = auth()->user(); @@ -32,66 +33,75 @@ class SearchController extends Controller } - private function clientMap(User $user) { + private function clientMap(User $user) + { return Client::query() ->company() - ->when($user->cannot('view_all') || $user->cannot('view_client'), function ($query) use($user) { + ->where('is_deleted', 0) + ->when($user->cannot('view_all') || $user->cannot('view_client'), function ($query) use ($user) { $query->where('user_id', $user->id); }) ->cursor() - ->map(function ($client){ - return [ - 'name' => $client->present()->name(), - 'type' => '/client', - 'id' => $client->hashed_id, - 'path' => "/clients/{$client->hashed_id}/edit", - 'heading' => ctrans('texts.clients') - ]; + ->map(function ($client) { + return [ + 'name' => $client->present()->name(), + 'type' => '/client', + 'id' => $client->hashed_id, + 'path' => "/clients/{$client->hashed_id}/edit" + ]; }); } - private function clientContactMap(User $user) { + private function clientContactMap(User $user) + { return ClientContact::query() ->company() ->with('client') - ->when($user->cannot('view_all') || $user->cannot('view_client'), function ($query) use($user) { + ->whereHas('client', function ($q) { + $q->where('is_deleted', 0); + }) + ->when($user->cannot('view_all') || $user->cannot('view_client'), function ($query) use ($user) { $query->where('user_id', $user->id); }) ->cursor() - ->map(function ($contact){ - return [ - 'name' => $contact->present()->search_display(), - 'type' => '/client_contact', - 'id' => $contact->client->hashed_id, - 'path' => "/clients/{$contact->client->hashed_id}", - 'heading' => ctrans('texts.contacts') - ]; + ->map(function ($contact) { + return [ + 'name' => $contact->present()->search_display(), + 'type' => '/client_contact', + 'id' => $contact->client->hashed_id, + 'path' => "/clients/{$contact->client->hashed_id}" + ]; }); } - private function invoiceMap(User $user) { + private function invoiceMap(User $user) + { return Invoice::query() ->company() ->with('client') - ->when($user->cannot('view_all') || $user->cannot('view_invoice'), function ($query) use($user) { + ->where('is_deleted', 0) + ->whereHas('client', function ($q) { + $q->where('is_deleted', 0); + }) + ->when($user->cannot('view_all') || $user->cannot('view_invoice'), function ($query) use ($user) { $query->where('user_id', $user->id); }) ->cursor() - ->map(function ($invoice){ - return [ - 'name' => $invoice->client->present()->name() . ' - ' . $invoice->number, - 'type' => '/invoice', - 'id' => $invoice->hashed_id, - 'path' => "/invoices/{$invoice->hashed_id}/edit", - 'heading' => ctrans('texts.invoices') - ]; + ->map(function ($invoice) { + return [ + 'name' => $invoice->client->present()->name() . ' - ' . $invoice->number, + 'type' => '/invoice', + 'id' => $invoice->hashed_id, + 'path' => "/clients/{$invoice->hashed_id}/edit" + ]; }); } - private function settingsMap() { + private function settingsMap() + { $paths = [ 'user_details' => '/settings/user_details', @@ -103,7 +113,7 @@ class SearchController extends Controller 'custom_fields' => '/settings/user_details/custom_fields', 'preferences' => '/settings/user_details/preferences', 'company_details' => '/settings/company_details', - 'company_details,details' => '/settings/company_details/', + 'company_details,details' => '/settings/company_details/details', 'company_details,address' => '/settings/company_details/address', 'company_details,logo' => '/settings/company_details/logo', 'company_details,defaults' => '/settings/company_details/defaults', @@ -181,7 +191,6 @@ class SearchController extends Controller 'path' => $value, 'type' => $transkey, 'name' => $translation, - 'heading' => ctrans('texts.settings') ]; } From 12b26e183bcad572b988246faad61509aa420498 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 20 Sep 2023 22:16:25 +1000 Subject: [PATCH 2/2] v5.7.17 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index d6542901dfb1..0935ec51dbd1 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.7.16 \ No newline at end of file +5.7.17 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 3fee705c8da1..fffa8f391d66 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,8 +15,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION','5.7.16'), - 'app_tag' => env('APP_TAG','5.7.16'), + 'app_version' => env('APP_VERSION','5.7.17'), + 'app_tag' => env('APP_TAG','5.7.17'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),