feat: auto-assign default shift and attendance policy if left blank
This commit is contained in:
@@ -242,10 +242,10 @@ class EmployeeController extends Controller
|
||||
'date_of_birth' => 'required|date',
|
||||
'gender' => 'required|in:male,female,other',
|
||||
'profile_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
'shift_id' => 'required|exists:shifts,id',
|
||||
'shift_id' => 'nullable|exists:shifts,id',
|
||||
'rest_days' => 'nullable|array',
|
||||
'rest_days.*' => 'string|in:monday,tuesday,wednesday,thursday,friday,saturday,sunday',
|
||||
'attendance_policy_id' => 'required|exists:attendance_policies,id',
|
||||
'attendance_policy_id' => 'nullable|exists:attendance_policies,id',
|
||||
'salary' => 'required|numeric|min:0',
|
||||
|
||||
// Employment details
|
||||
@@ -372,7 +372,20 @@ class EmployeeController extends Controller
|
||||
$employee->branch_id = $request->branch_id;
|
||||
$employee->department_id = $request->department_id;
|
||||
$employee->designation_id = $request->designation_id;
|
||||
$employee->shift_id = $request->shift_id;
|
||||
$shiftId = $request->shift_id;
|
||||
if (empty($shiftId)) {
|
||||
$defaultShift = \App\Models\Shift::whereIn('created_by', getCompanyAndUsersId())->where('status', 'active')->first();
|
||||
$shiftId = $defaultShift ? $defaultShift->id : null;
|
||||
}
|
||||
$employee->shift_id = $shiftId;
|
||||
|
||||
$policyId = $request->attendance_policy_id;
|
||||
if (empty($policyId)) {
|
||||
$defaultPolicy = \App\Models\AttendancePolicy::whereIn('created_by', getCompanyAndUsersId())->where('status', 'active')->first();
|
||||
$policyId = $defaultPolicy ? $defaultPolicy->id : null;
|
||||
}
|
||||
$employee->attendance_policy_id = $policyId;
|
||||
|
||||
$employee->rest_days = $request->rest_days;
|
||||
$employee->date_of_joining = $request->date_of_joining;
|
||||
$employee->employment_type = $request->employment_type;
|
||||
@@ -579,10 +592,10 @@ class EmployeeController extends Controller
|
||||
'date_of_birth' => 'required|date',
|
||||
'gender' => 'required|in:male,female,other',
|
||||
'profile_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
'shift_id' => 'required|exists:shifts,id',
|
||||
'shift_id' => 'nullable|exists:shifts,id',
|
||||
'rest_days' => 'nullable|array',
|
||||
'rest_days.*' => 'string|in:monday,tuesday,wednesday,thursday,friday,saturday,sunday',
|
||||
'attendance_policy_id' => 'required|exists:attendance_policies,id',
|
||||
'attendance_policy_id' => 'nullable|exists:attendance_policies,id',
|
||||
'salary' => 'required|numeric|min:0',
|
||||
|
||||
// Employment details
|
||||
@@ -665,9 +678,21 @@ class EmployeeController extends Controller
|
||||
$employee->employee_id = $request->employee_id;
|
||||
}
|
||||
$employee->biometric_emp_id = $request->biometric_emp_id;
|
||||
$employee->shift_id = $request->shift_id;
|
||||
$shiftId = $request->shift_id;
|
||||
if (empty($shiftId)) {
|
||||
$defaultShift = \App\Models\Shift::whereIn('created_by', getCompanyAndUsersId())->where('status', 'active')->first();
|
||||
$shiftId = $defaultShift ? $defaultShift->id : null;
|
||||
}
|
||||
$employee->shift_id = $shiftId;
|
||||
|
||||
$policyId = $request->attendance_policy_id;
|
||||
if (empty($policyId)) {
|
||||
$defaultPolicy = \App\Models\AttendancePolicy::whereIn('created_by', getCompanyAndUsersId())->where('status', 'active')->first();
|
||||
$policyId = $defaultPolicy ? $defaultPolicy->id : null;
|
||||
}
|
||||
$employee->attendance_policy_id = $policyId;
|
||||
|
||||
$employee->rest_days = $request->rest_days;
|
||||
$employee->attendance_policy_id = $request->attendance_policy_id;
|
||||
$employee->phone = $request->phone;
|
||||
$employee->date_of_birth = $request->date_of_birth;
|
||||
$employee->gender = $request->gender;
|
||||
|
||||
Reference in New Issue
Block a user