|
@@ -421,6 +421,68 @@ class AdminController extends Controller
|
|
$templateContent = file_get_contents($path);
|
|
$templateContent = file_get_contents($path);
|
|
return $this->pass($templateContent);
|
|
return $this->pass($templateContent);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function bdtDevices(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $filters = $request->all();
|
|
|
|
+ $bdtDevices = BDTDevice::query();
|
|
|
|
+
|
|
|
|
+ $imei = $request->input('imei');
|
|
|
|
+ if($imei){
|
|
|
|
+ $bdtDevices = $bdtDevices->where('imei', '=', $imei);
|
|
|
|
+ }
|
|
|
|
+ $client = $request->input('client');
|
|
|
|
+
|
|
|
|
+ if($client){
|
|
|
|
+ $client = '%'.$client.'%';
|
|
|
|
+ $bdtDevices = $bdtDevices->whereHas('clientBDTDevice', function($cbdtdQuery) use ($client) {
|
|
|
|
+ return $cbdtdQuery->whereHas('client', function($clientQuery) use ($client){
|
|
|
|
+ return $clientQuery->where(function($q) use ($client){
|
|
|
|
+ return $q->where('name_first', 'ilike', $client)
|
|
|
|
+ ->orWhere('name_last', 'ilike', $client)
|
|
|
|
+ ->orWhere('cell_number', 'ilike', $client)
|
|
|
|
+ ->orWhereRaw("name_first||' '||name_last ILIKE "."'".$client."'");
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $is_issued = $request->input('is_issued');
|
|
|
|
+ if($is_issued){
|
|
|
|
+ if($is_issued == 'YES'){
|
|
|
|
+ $bdtDevices = $bdtDevices->whereHas('clientBDTDevice');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($is_issued == 'NO'){
|
|
|
|
+ $bdtDevices = $bdtDevices->whereDoesntHave('clientBDTDevice');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $is_issued = $request->input('is_issued');
|
|
|
|
+ if($is_issued){
|
|
|
|
+ if($is_issued == 'YES'){
|
|
|
|
+ $bdtDevices = $bdtDevices->whereHas('clientBDTDevice');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($is_issued == 'NO'){
|
|
|
|
+ $bdtDevices = $bdtDevices->whereDoesntHave('clientBDTDevice');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ $mcp = $request->input('mcp');
|
|
|
|
+ if($mcp){
|
|
|
|
+ $bdtDevices = $bdtDevices->whereHas('clientBDTDevice', function($cbdtdQuery) use ($mcp) {
|
|
|
|
+ return $cbdtdQuery->whereHas('client', function($clientQuery) use ($mcp){
|
|
|
|
+ $mcpPro = Pro::where('uid', $mcp)->first();
|
|
|
|
+ return $clientQuery->where('mcp_pro_id', $mcpPro->id);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $bdtDevices = $bdtDevices->paginate(20);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return view('app.admin.bdt_devices', compact('bdtDevices', 'filters'));
|
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
|
|
|
+}
|