@php $name = isset($element['name']) ? $element['name'] : 'fillEmployeeIdForPos'; $id = 'allfillEmployeeIdForPos'; $label = isset($element['label']) ? $element['label'] : 'Employee:'; $allOption = isset($element['alloption']) ? $element['alloption'] : 'yes'; $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']); } $userAccessibleBranchIds = App\Service\Service::getEngagedBranchesByUserId(Auth::user()->id); if($allOption == 'no'){ $alloptions = ''; $employees = DB::table('hr_emp_general_info AS empGnl') ->join('hr_emp_org_info AS empOrg', 'empOrg.emp_id_fk', 'empGnl.id') ->whereIntegerInRaw('empOrg.branch_id_fk', $userAccessibleBranchIds) ->where([ ['empOrg.status', 'Active'], ['empOrg.job_status', 'Present'], ]) ->select(DB::raw("CONCAT(LPAD(empGnl.emp_id, 5, 0), ' - ', empGnl.emp_name_english) AS name"), 'empGnl.id as id')->pluck('name', 'id')->toArray(); // $employees = DB::table('hr_emp_general_info') // ->select(DB::raw("CONCAT('emp_id', ' - ', 'emp_name_english') AS name,id"))->pluck('name', 'id')->toArray(); if (isset($element['options'])) { $options = $element['options']; }else{ $options = DB::table('hr_emp_general_info AS empGnl') ->join('hr_emp_org_info AS empOrg', 'empOrg.emp_id_fk', 'empGnl.id') ->whereIntegerInRaw('empOrg.branch_id_fk', $userAccessibleBranchIds) ->where([ ['empOrg.status', 'Active'], ['empOrg.job_status', 'Present'], ]) ->select(DB::raw("CONCAT(LPAD(empGnl.emp_id, 5, 0), ' - ', empGnl.emp_name_english) AS nameWithCode"), 'empGnl.id as id')->pluck('nameWithCode', 'id')->all(); // $options = DB::table('hr_emp_general_info')->select(DB::raw("CONCAT(LPAD(emp_id, 5, 0), ' - ', emp_name_english) AS nameWithCode"), 'id') // ->pluck('nameWithCode', 'id') // ->all(); } }else{ $alloptions = ['' => 'All']; // $employees = $alloptions + DB::table('hr_emp_general_info') // ->select(DB::raw("CONCAT('emp_id', ' - ', 'emp_name_english') AS name,id"))->pluck('name', 'id')->toArray(); $employees = $alloptions + DB::table('hr_emp_general_info AS empGnl') ->join('hr_emp_org_info AS empOrg', 'empOrg.emp_id_fk', 'empGnl.id') ->where([ ['empOrg.status', 'Active'], ['empOrg.job_status', 'Present'], ]) ->select(DB::raw("CONCAT(LPAD(empGnl.emp_id, 5, 0), ' - ', empGnl.emp_name_english) AS name"), 'empGnl.id as id')->pluck('name', 'id')->toArray(); if (isset($element['options'])) { $options = $element['options']; }else{ $options = $alloptions + DB::table('hr_emp_general_info AS empGnl') ->join('hr_emp_org_info AS empOrg', 'empOrg.emp_id_fk', 'empGnl.id') ->where([ ['empOrg.status', 'Active'], ['empOrg.job_status', 'Present'], ]) ->select(DB::raw("CONCAT(LPAD(empGnl.emp_id, 5, 0), ' - ', empGnl.emp_name_english) AS nameWithCode"), 'empGnl.id as id')->pluck('nameWithCode', 'id')->all(); // $options = $alloptions + DB::table('hr_emp_general_info')->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'] : ''; @endphp