@@ -117,7 +117,15 @@ public function fields(NovaRequest $request)
117117 */
118118 public function cards (NovaRequest $ request )
119119 {
120- $ model = ModelsTindakLanjut::where ('tahun ' , session ('year ' ));
120+ $ currentDate = now ();
121+ $ startOfYear = $ currentDate ->copy ()->startOfYear ();
122+ $ triwulan = match (true ) {
123+ $ currentDate ->between ($ startOfYear , $ startOfYear ->copy ()->addMonths (3 )->addDays (10 )) => 4 ,
124+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (3 ), $ startOfYear ->copy ()->addMonths (6 )->addDays (10 )) => 1 ,
125+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (6 ), $ startOfYear ->copy ()->addMonths (9 )->addDays (10 )) => 2 ,
126+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (9 ), $ startOfYear ->copy ()->endOfYear ()->addDays (10 )) => 3 ,
127+ };
128+ $ model = ModelsTindakLanjut::where ('tahun ' , session ('year ' ))->where ('triwulan ' , $ triwulan );
121129
122130 return [
123131 MetricPartition::make ($ model , 'unit_kerja_id ' , 'unit-kerja-tl ' , 'Unit Kerja ' )
@@ -171,6 +179,17 @@ protected static function afterValidation(NovaRequest $request, $validator)
171179
172180 public static function indexQuery (NovaRequest $ request , $ query )
173181 {
174- return $ query ->where ('tahun ' , session ('year ' ))->withCount (['perjanjianKinerja ' , 'pelaksanaanTindakLanjut ' ]);
182+ $ currentDate = now ();
183+ $ startOfYear = $ currentDate ->copy ()->startOfYear ();
184+ $ triwulan = match (true ) {
185+ $ currentDate ->between ($ startOfYear , $ startOfYear ->copy ()->addMonths (3 )->addDays (10 )) => 4 ,
186+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (3 ), $ startOfYear ->copy ()->addMonths (6 )->addDays (10 )) => 1 ,
187+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (6 ), $ startOfYear ->copy ()->addMonths (9 )->addDays (10 )) => 2 ,
188+ $ currentDate ->between ($ startOfYear ->copy ()->addMonths (9 ), $ startOfYear ->copy ()->endOfYear ()->addDays (10 )) => 3 ,
189+ };
190+
191+ return $ query ->where ('tahun ' , session ('year ' ))
192+ ->where ('triwulan ' , $ triwulan )
193+ ->withCount (['perjanjianKinerja ' , 'pelaksanaanTindakLanjut ' ]);
175194 }
176195}
0 commit comments