Browse Source

add status filter

pull/3/head
wahyu 1 year ago
parent
commit
1a02dd2d03
  1. 12
      app/Http/Controllers/UserToActivityController.php

12
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);
}

Loading…
Cancel
Save