Browse Source

fix date filter

pull/3/head
wahyu 1 year ago
parent
commit
366ac14777
  1. 16
      app/Http/Controllers/UserToActivityController.php

16
app/Http/Controllers/UserToActivityController.php

@ -131,10 +131,6 @@ class UserToActivityController extends Controller
$payload = $request->all();
if (isset($payload['join_column'])) {
$join_column = $payload['join_column'];
$startDate = $join_column['start_date'];
$endDate = $join_column['end_date'];
$startDate = date("Y-m-d H:i:sO", strtotime($startDate));
$endDate = date("Y-m-d H:i:sO", strtotime($endDate));
unset($payload['join_column']);
}
@ -142,14 +138,18 @@ class UserToActivityController extends Controller
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
if (isset($join_column)) {
$startDate = $join_column['start_date'];
$endDate = $join_column['end_date'];
$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) {
$query
->where('m_proyek.mulai_proyek', '<=', $startDate)
->where('m_proyek.akhir_proyek', '>=', $endDate)
->where('m_proyek.mulai_proyek', '>=', $startDate)
->where('m_proyek.akhir_proyek', '<=', $endDate)
->where(function ($query) use ($endDate, $startDate) {
$query
->where('m_activity.start_date', '<=', $startDate)
->where('m_activity.end_date', '>=', $endDate);
->where('m_activity.start_date', '>=', $startDate)
->where('m_activity.end_date', '<=', $endDate);
});
});
}

Loading…
Cancel
Save