'id', ); $level = Auth::user()->level; if (strtoupper($level) == 'SUPERADMIN' || strtoupper($level) == 'GENERAL MANAGER' || strtoupper($level) == 'FINANCE MANAGER' || strtoupper($level) == 'SUPPLY CHAIN MANAGER' || strtoupper($level) == 'MARKETING MANAGER' || strtoupper($level) == 'PROJECT MANAGER') { $totalData = Project::count(); $totalFiltered = $totalData; $limit = $request->input('length'); $start = $request->input('start'); $order = $columns[$request->input('order.0.column')]; $dir = $request->input('order.0.dir'); if (empty($request->input('search.value'))) { $projects = Project::offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); }else{ $search = $request->input('search.value'); $projects = Project::where('projects.name', 'LIKE', "%{$search}%") ->offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); $totalFiltered = Project::where('projects.name', 'LIKE', "%{$search}%") ->count(); } } else { $totalData = Project::where('id_user', Auth::user()->id)->count(); $totalFiltered = $totalData; $limit = $request->input('length'); $start = $request->input('start'); $order = $columns[$request->input('order.0.column')]; $dir = $request->input('order.0.dir'); if (empty($request->input('search.value'))) { $projects = Project::where('id_user', Auth::user()->id) ->offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); }else{ $search = $request->input('search.value'); $projects = Project::where([['projects.name', 'LIKE', "%{$search}%"], ['id_user', Auth::user()->id]]) ->offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); $totalFiltered = Project::where([['projects.name', 'LIKE', "%{$search}%"],['id_user', Auth::user()->id]]) ->count(); } } $data = array(); if (!empty($projects)) { foreach ($projects as $row) { $nestedData['project'] = $row->name; if($row->id_user == NULL) { $nestedData['created_by'] = ''; } else { $nestedData['created_by'] = $row->user->fullname; } $nestedData['opsi'] = "
"; $nestedData['opsi'] .= " detail
"; $data[] = $nestedData; } } $json_data = array( "draw" => intval($request->input('draw')), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => $data, ); echo json_encode($json_data); } } }else{ $project = Project::findOrFail($id); $count = RabDetailMandor::where('id_rab',$project->rab->id)->count(); if ($count > 0) { $ahsS = AhsKategori::with(['subkategoris.ahsS' => function($q) use ($project){ $q->whereHas('rabDetailMandor',function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); })->with(['rabDetailMandor' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }])->with(['rabDetail' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }]); }])->with(['subkategoris.vendors' => function($q) use ($project){ $q->whereHas('rabDetailMandor',function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); })->with(['rabDetailMandor' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }])->with(['rabDetail' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }]);; }])->orderBy('urutan','asc')->get(); }else{ $ahsS = null; } return view('staff.progress-mandor-detail',compact('ahsS','project')); } } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { RabDetailMandor::destroy($id); return redirect()->back()->with('msg','item berhasil dihapus'); } }