From 1a02dd2d03dea20092536068fc0dded0f14ab505 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 26 Sep 2023 13:54:21 +0700 Subject: [PATCH] add status filter --- app/Http/Controllers/UserToActivityController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index 5951aa6..c422cf6 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\UserToActivity; use App\Models\Activity; +use App\Models\AssignMaterial; use Datatables; class UserToActivityController extends Controller @@ -140,6 +141,7 @@ class UserToActivityController extends Controller if (isset($join_column)) { $startDate = $join_column['start_date']; $endDate = $join_column['end_date']; + $status = $join_column['status']; $startDate = date("Y-m-d H:i:sO", strtotime($startDate)); $endDate = date("Y-m-d H:i:sO", strtotime($endDate)); $builder->where(function ($query) use ($startDate, $endDate) { @@ -154,6 +156,16 @@ class UserToActivityController extends Controller }); } $dataGet = $builder->get(); + if (isset($status) && $status != "") { + $filteredData = []; + foreach ($dataGet as $value) { + $assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first(); + if ($assignMaterial->status_activity == $status) { + $filteredData[] = $value; + } + } + $dataGet = $filteredData; + } $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); }