public function index(ClientSurvey $client_survey, DatatableSearch $request): JsonResponse 	{ 		$applicants = $client_survey 		->applicants() 		->select([ 			'id', 			'ip_address', 			'filled', 			'draft', 			'is_offline', 			'active', 			'created_at', 		]) 		->withExists('latestMetadata');  		return DataTables::eloquent($applicants) 		->order(function ($query) use ($request) { 			$order_array = $request->get('order') ?? []; 			$columns_array = $request->columns;  			if (!empty($order_array)) { 				foreach (array_column($order_array, 'dir', 'column') as $column_index => $order_direction) { 					$query->orderBy($columns_array[$column_index]['name'], $order_direction); 				} 			} else { 				$query->latest(); 			} 		}) 		->filter(function ($query) use ($request) { 			$search_term = $request->search['value'] ?? null;  			if ($search_term) { 				$query->search($search_term); 			} 		}) 		->addColumn('metadata', function (Applicant $row) { 			$applicant_metadata_modal = json_encode([ 				'api' => route('api.applicants.metadata', [$row->id]), 				'token' => auth()->user()->token(), 				'title' => __('applicants.metadata'), 			]);  			if ($row->latest_metadata_exists) { 				return '<a href="#" title="' . __('applicants.metadata') . '" data-modal-data=\'' . $applicant_metadata_modal . '\' data-toggle="modal" data-target="#applicant-metadata-modal" class="text-hover-primary"> 					<i class="fas fa-code"></i> 				</a>'; 			}  			return '-'; 		}) 		->addColumn('filled', function (Applicant $row) { 			$state = $row->filled ? 'success' : 'danger'; 			$label = $row->filled ? __('global.yes') : __('global.no');  			return '<span class="label label-' . $state . ' label-inline">' . $label . '</span>'; 		}) 		->addColumn('draft', function (Applicant $row) { 			$state = $row->draft ? 'success' : 'danger'; 			$label = $row->draft ? __('global.yes') : __('global.no');  			return '<span class="label label-' . $state . ' label-inline">' . $label . '</span>'; 		}) 		->addColumn('is_offline', function (Applicant $row) { 			$state = $row->is_offline ? 'success' : 'danger'; 			$label = $row->is_offline ? __('global.yes') : __('global.no');  			return '<span class="label label-' . $state . ' label-inline">' . $label . '</span>'; 		}) 		->addColumn('active', function (Applicant $row) { 			$state = $row->active ? 'success' : 'danger'; 			$label = $row->active ? __('global.yes') : __('global.no');  			return '<span class="label label-' . $state . ' label-inline">' . $label . '</span>'; 		}) 		->addColumn('edit', function (Applicant $row) { 			return '<a href="' . route('applicant-surveys-ba.edit', ['id' => $row->id]) . '" title="' . __('global.edit') . '" data-container="body" data-toggle="tooltip" data-placement="left" class="btn btn-icon btn-light btn-hover-primary btn-sm"> 				<i class="fa fa-edit text-primary"></i> 			</a>'; 		}) 		->addColumn('created_at', function (Applicant $row) { 			return formatLocalTimestamp($row->created_at); 		}) 		->addColumn('checkbox', function (Applicant $row) { 			return '<label class="checkbox checkbox-single checkbox-primary"> 				<input type="checkbox" name="values[]" value="' . $row->id . '" class="options-form"><span></span> 			</label>'; 		}) 		->rawColumns(['metadata', 'filled', 'draft', 'is_offline', 'active', 'edit', 'created_at', 'checkbox']) 		->toJson(); 	}