'Production', 'description' => 'productions settings' ]; } public function onCalculateReportDaily() { $currentDate = Carbon::now()->timezone('UTC +05:00'); $currentDateFormat = $currentDate->format('Y-m-d'); $data = post(); $excruiter = $this->param("excruiter"); $currentDateLast = ProductionModel::whereDate('created_at', date($currentDateFormat))->where('excruiter_id', $excruiter)->orderBy('id', 'DESC')->first(); $currentDateFirst = ProductionModel::whereDate('created_at', date($currentDateFormat))->where('excruiter_id', $excruiter)->orderBy('id', 'ASC')->first(); $diffMinutes = Carbon::parse($currentDateLast->time)->diffInMinutes($currentDateFirst->time); $currentDateProductionAll = ProductionModel::whereDate('created_at', date($currentDateFormat))->where('excruiter_id', $excruiter)->avg('all_amount'); // $testq = PivotProductionModel::whereDate('created_at', date($currentDateFormat)) // ->where('excruiter_id', $excruiter) // ->select('id', 'product_name', 'excruiter_id',DB::raw('round(AVG(amount),0) as average'), DB::raw('round(AVG(amount_percentage),0) as average_percentage')) // ->groupBy('product_id') // ->get(); $pivotFirsts = PivotProductionModel::where('production_id', $currentDateFirst->id)->get(); $pivotLasts = PivotProductionModel::where('production_id', $currentDateLast->id)->get(); $allData = array( "all" => array( "hours" => floor($diffMinutes / 60).' sagat '.($diffMinutes - floor($diffMinutes / 60) * 60).' minut', "avg_all_amount" => number_format($currentDateProductionAll, 2), ) ); $producedAll = $currentDateFirst->all_amount - $currentDateLast->all_amount; $html_data = '