diff --git a/app/Http/Controllers/EmployeeController.php b/app/Http/Controllers/EmployeeController.php index db6955e7d..329a685c1 100644 --- a/app/Http/Controllers/EmployeeController.php +++ b/app/Http/Controllers/EmployeeController.php @@ -215,9 +215,9 @@ class EmployeeController extends Controller 'biometric_emp_id' => 'nullable|string|max:255|unique:employees,biometric_emp_id', 'email' => 'required|email|max:255|unique:users,email', 'password' => 'required|string|min:8', - 'phone' => 'required|string|max:20', - 'date_of_birth' => 'required|date', - 'gender' => 'required|in:male,female,other', + 'phone' => 'nullable|string|max:20', + 'date_of_birth' => 'nullable|date', + 'gender' => 'nullable|in:male,female,other', 'profile_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', 'shift_id' => 'nullable|exists:shifts,id', 'rest_days' => 'nullable|array', @@ -226,12 +226,12 @@ class EmployeeController extends Controller 'salary' => 'required|numeric|min:0', // Employment details - 'branch_id' => 'required|exists:branches,id', - 'department_id' => 'required|exists:departments,id', - 'designation_id' => 'required|exists:designations,id', - 'date_of_joining' => 'required|date', - 'employment_type' => 'required|string|max:50', - 'employee_status' => 'required|string|max:50', + 'branch_id' => 'nullable|exists:branches,id', + 'department_id' => 'nullable|exists:departments,id', + 'designation_id' => 'nullable|exists:designations,id', + 'date_of_joining' => 'nullable|date', + 'employment_type' => 'nullable|string|max:50', + 'employee_status' => 'nullable|string|max:50', // Contact information 'address_line_1' => 'nullable|string|max:255', @@ -539,9 +539,9 @@ class EmployeeController extends Controller 'biometric_emp_id' => 'nullable|string|max:255|unique:employees,biometric_emp_id,' . $employee->id, 'email' => 'required|email|max:255|unique:users,email,' . $employee->user_id, 'password' => 'nullable|string|min:8', - 'phone' => 'required|string|max:20', - 'date_of_birth' => 'required|date', - 'gender' => 'required|in:male,female,other', + 'phone' => 'nullable|string|max:20', + 'date_of_birth' => 'nullable|date', + 'gender' => 'nullable|in:male,female,other', 'profile_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', 'shift_id' => 'nullable|exists:shifts,id', 'rest_days' => 'nullable|array', @@ -550,12 +550,12 @@ class EmployeeController extends Controller 'salary' => 'required|numeric|min:0', // Employment details - 'branch_id' => 'required|exists:branches,id', - 'department_id' => 'required|exists:departments,id', - 'designation_id' => 'required|exists:designations,id', - 'date_of_joining' => 'required|date', - 'employment_type' => 'required|string|max:50', - 'employee_status' => 'required|string|max:50', + 'branch_id' => 'nullable|exists:branches,id', + 'department_id' => 'nullable|exists:departments,id', + 'designation_id' => 'nullable|exists:designations,id', + 'date_of_joining' => 'nullable|date', + 'employment_type' => 'nullable|string|max:50', + 'employee_status' => 'nullable|string|max:50', // Contact information 'address_line_1' => 'nullable|string|max:255', diff --git a/fix_required.py b/fix_required.py new file mode 100644 index 000000000..54e1e6787 --- /dev/null +++ b/fix_required.py @@ -0,0 +1,60 @@ +import re +import sys + +def remove_required(filepath): + with open(filepath, 'r') as f: + content = f.read() + + # Fields that should remain required + # name, email, password, salary + # We will remove `required` from Label, Input, and Select for all other fields. + + # Let's find all occurrences of `required` and carefully remove them unless they are for our core fields. + lines = content.split('\n') + out_lines = [] + + current_field = None + + for line in lines: + # Detect field context + match = re.search(r'(?:htmlFor|id)="([^"]+)"', line) + if match: + current_field = match.group(1) + + # Also detect gender which uses RadioGroup + if 'id="gender-male"' in line: + current_field = 'gender' + + if '' in line: + line = line.replace('