searchBy = [ 'PID' => 'PID', 'PATCHNAME' => 'Patch Name', 'PDESC' => 'Description', 'MAJOR_VERSION' => 'Major Vaersion', 'Remark' => 'Remark' ]; $this->message = session('message'); } public function render() { $results = []; if ($this->action == 'list') { DB::table('conf_server_pendding')->index(['ServerID', 'PatchID']); $numServerSubquery = DB::table('conf_server_pendding as p2') ->select(DB::raw('count(p2.ServerID) as NUMSERVER'), 'p2.PatchID') ->groupBy('p2.PatchID'); // Query หลัก $query = ConfSmartUpdate::from('conf_smartupdate as p1') ->select('p1.PID', 'p1.PATCHNAME', 'p1.PDESC', 'p1.PDATE', 'p1.PLEVEL', 'p1.Remark', 'p3.NUMSERVER') ->leftJoinSub($numServerSubquery, 'p3', function ($join) { $join->on('p1.PID', '=', 'p3.PatchID'); }); if ($this->searchSelected && $this->keyword) { $query->where($this->searchSelected, 'LIKE', $this->keyword . '%'); } $query->orderBy('p1.PID', 'DESC'); $results = $query->paginate($this->perPage); } // $results = []; // dd($results); return view('livewire.pages.send-patch.send-patch-index', compact('results')); } public function search() { $this->resetPage(); } public function showpatchEditForm($pid) { $this->editPid = $pid; $this->action = 'edit'; } }