diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index dad48a9..540dd40 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Divisi; +use Illuminate\Support\Facades\Log; class DivisiController extends Controller { @@ -83,7 +84,11 @@ class DivisiController extends Controller public function search(Request $request) { - $parentDivisi = Divisi::whereNull('parent')->with('children')->get(); + $companyId = $request->input('columns.0.value'); + $parentDivisi = Divisi::whereNull('parent') + ->where('company_id', $companyId) + ->with('children') + ->get(); $divisions = []; foreach ($parentDivisi as $objRow) { $objRow->children = $this->getAllChildren($objRow); @@ -95,16 +100,6 @@ class DivisiController extends Controller return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200); - - // $payload = $request->all(); - // $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); - // $builder = $dataBuilder['builder']; - // $countBuilder = $dataBuilder['count']; - // $dataGet = $builder->get(); - // $totalRecord = $countBuilder->count(); - // return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); - //return $this->list(); - // cant use builder for this case } public function list()