|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\User; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
use App\User; |
|
7
|
|
|
|
|
8
|
|
|
class AdvanceSearchController extends Controller |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Serach for Mobile,Email,Country. |
|
12
|
|
|
*/ |
|
13
|
|
|
public function getMobEmCoun($join, $mobile, $email, $country) |
|
14
|
|
|
{ |
|
15
|
|
|
if ($mobile) { |
|
16
|
|
|
$join = $join->where('mobile', $mobile); |
|
17
|
|
|
} |
|
18
|
|
|
if ($email) { |
|
19
|
|
|
$join = $join->where('email', 'LIKE', '%'.$email.'%'); |
|
20
|
|
|
} |
|
21
|
|
|
if ($country) { |
|
22
|
|
|
$join = $join->where('country', $country); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
return $join; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Serach for industry,company_type,company_size. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getInCtCs($join, $industry, $company_type, $company_size) |
|
32
|
|
|
{ |
|
33
|
|
|
if ($industry) { |
|
34
|
|
|
$join = $join->where('bussiness', $industry); |
|
35
|
|
|
} |
|
36
|
|
|
if ($company_type) { |
|
37
|
|
|
$join = $join->where('company_type', $company_type); |
|
38
|
|
|
} |
|
39
|
|
|
if ($company_size) { |
|
40
|
|
|
$join = $join->where('company_size', $company_size); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $join; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Serach for Role,Position. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getRolPos($join, $role, $position) |
|
50
|
|
|
{ |
|
51
|
|
|
if ($role) { |
|
52
|
|
|
$join = $join->where('role', $role); |
|
53
|
|
|
} |
|
54
|
|
|
if ($position) { |
|
55
|
|
|
$join = $join->where('position', $position); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return $join; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Serach for Registered From,tILL. |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getregFromTill($join,$reg_from, $reg_till) |
|
65
|
|
|
{ |
|
66
|
|
|
if ($reg_from) { |
|
67
|
|
|
$fromdate = date_create($reg_from); |
|
68
|
|
|
|
|
69
|
|
|
$from = date_format($fromdate, 'Y-m-d H:m:i'); |
|
70
|
|
|
$tills = date('Y-m-d H:m:i'); |
|
71
|
|
|
$cont = new \App\Http\Controllers\Order\ExtendedOrderController(); |
|
72
|
|
|
$tillDate = $cont->getTillDate($from, $reg_till, $tills); |
|
73
|
|
|
$join = $join->whereBetween('created_at', [$from, $tillDate]); |
|
74
|
|
|
} |
|
75
|
|
|
if ($reg_till) { |
|
76
|
|
|
$tilldate = date_create($reg_till); |
|
77
|
|
|
$till = date_format($tilldate, 'Y-m-d H:m:i'); |
|
78
|
|
|
$froms = User::first()->created_at; |
|
79
|
|
|
$cont = new \App\Http\Controllers\Order\ExtendedOrderController(); |
|
80
|
|
|
$fromDate = $cont->getFromDate($reg_from, $froms); |
|
81
|
|
|
$join = $join->whereBetween('created_at', [$fromDate, $till]); |
|
82
|
|
|
} |
|
83
|
|
|
return $join; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Serach for Name,UserName,Company. |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getNamUserCom($join, $name, $username, $company) |
|
91
|
|
|
{ |
|
92
|
|
|
if ($name) { |
|
93
|
|
|
$join = $join->where('first_name', 'LIKE', '%'.$name.'%') |
|
94
|
|
|
->orWhere('last_name', 'LIKE', '%'.$name.'%'); |
|
95
|
|
|
} |
|
96
|
|
|
if ($username) { |
|
97
|
|
|
$join = $join->where('user_name', 'LIKE', '%'.$username.'%'); |
|
98
|
|
|
} |
|
99
|
|
|
if ($company) { |
|
100
|
|
|
$join = $join->where('company', 'LIKE', '%'.$company.'%'); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $join; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|