Skip to content

Commit a46e92b

Browse files
SecurIDasbiin
andauthored
fix: correct ordering of contacts based on preferred displaying of names (#6962)
Co-authored-by: Alexis Saettler <[email protected]>
1 parent 1b351e4 commit a46e92b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/Domains/Contact/ManageContact/Web/Controllers/ContactController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,23 @@
2121
use Illuminate\Support\Facades\Gate;
2222
use Inertia\Inertia;
2323

24+
use function Safe\preg_replace;
25+
2426
class ContactController extends Controller
2527
{
2628
public function index(Request $request, Vault $vault)
2729
{
2830
$contacts = $vault->contacts()
2931
->where('listed', true);
3032

33+
$column_to_order = preg_replace('/^%([a-z_]+)%.*$/', '$1', Auth::user()->name_order);
34+
3135
switch (Auth::user()->contact_sort_order) {
3236
case User::CONTACT_SORT_ORDER_ASC:
33-
$contacts = $contacts->orderBy('last_name', 'asc');
37+
$contacts = $contacts->orderBy($column_to_order, 'asc');
3438
break;
3539
case User::CONTACT_SORT_ORDER_DESC:
36-
$contacts = $contacts->orderBy('last_name', 'desc');
40+
$contacts = $contacts->orderBy($column_to_order, 'desc');
3741
break;
3842
default:
3943
$contacts = $contacts->orderBy('last_updated_at', 'desc');

0 commit comments

Comments
 (0)