@php $name = isset($element['name']) ? $element['name'] : 'fillCollectedBy'; $id = 'fillCollectedBy'; $label = isset($element['label']) ? $element['label'] : 'Collected By:'; $class = 'form-control custom-select2'; if (isset($element['attributes']['class'])) { $class .= ' ' . $element['attributes']['class']; } $attributes = ['id' => $id, 'class' => $class]; if (isset($element['attributes'])) { $attributes = array_merge($attributes, $element['attributes']); } $loggedBranch = App\Models\gnr\GnrBranch::select('name')->where('id', Auth::user()->branchId)->where('status',1)->first(); if($loggedBranch->name == 'Head Office'){ $dataEmp = DB::table('pos_collections')->whereNotNull('created_by')->groupBy('created_by')->pluck('created_by')->all(); }else{ $dataEmp = DB::table('pos_collections')->where('branch_id',Auth::user()->branchId)->whereNotNull('created_by')->groupBy('created_by')->pluck('created_by')->all(); } if(isset($element['options'])){ $options = $element['options']; } else{ $options = ['' => 'All'] + DB::table('hr_emp_general_info')->whereIn('id',$dataEmp)->select(DB::raw("CONCAT(LPAD(emp_id, 5, 0), ' - ', emp_name_english) AS nameWithCode"), 'id') ->pluck('nameWithCode', 'id') ->all(); } $defaultValue = isset($element['defaultValue']) ? $element['defaultValue'] : ''; $col = isset($element['col']) ? "col-md-" . $element['col'] : 'col-md-2'; @endphp