File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
app/Domains/Contact/ManageContact/Web/Controllers Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 21
21
use Illuminate \Support \Facades \Gate ;
22
22
use Inertia \Inertia ;
23
23
24
+ use function Safe \preg_replace ;
25
+
24
26
class ContactController extends Controller
25
27
{
26
28
public function index (Request $ request , Vault $ vault )
27
29
{
28
30
$ contacts = $ vault ->contacts ()
29
31
->where ('listed ' , true );
30
32
33
+ $ column_to_order = preg_replace ('/^%([a-z_]+)%.*$/ ' , '$1 ' , Auth::user ()->name_order );
34
+
31
35
switch (Auth::user ()->contact_sort_order ) {
32
36
case User::CONTACT_SORT_ORDER_ASC :
33
- $ contacts = $ contacts ->orderBy (' last_name ' , 'asc ' );
37
+ $ contacts = $ contacts ->orderBy ($ column_to_order , 'asc ' );
34
38
break ;
35
39
case User::CONTACT_SORT_ORDER_DESC :
36
- $ contacts = $ contacts ->orderBy (' last_name ' , 'desc ' );
40
+ $ contacts = $ contacts ->orderBy ($ column_to_order , 'desc ' );
37
41
break ;
38
42
default :
39
43
$ contacts = $ contacts ->orderBy ('last_updated_at ' , 'desc ' );
You can’t perform that action at this time.
0 commit comments