AI Review Center
Commit Review Workspace ?
Select a commit on the left to inspect quality, security, business value, findings, and suggested code changes.
Project AI Score
?
67%
Quality Avg
?
72%
Security Avg
?
54%
Reviews
?
37
Review Result ?
jattin01/army · bdfae45a
The commit includes improvements in handling pagination, file import validation, and structured error handling in StaffController. It has added validation for file imports and improved structured JSON response for import results. Bulk of the commented-out code for staff store method is replaced by new implementation handling children and dependents as arrays rather than JSON strings. However, there are some missing null checks, comments, and the exception catching could be broader but more explicit. Also, the commit message is non-descriptive and does not clarify the intent or scope of changes.
Quality
?
75%
Security
?
65%
Business Value
?
70%
Maintainability
?
68%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Insufficient Descriptive Detail
Where
commit message
Issue / Evidence
insufficient descriptive detail
Suggested Fix
provide a detailed commit message explaining the purpose and scope of the changes
Paginate() Is Called After Orderby, Better...
Where
app/Http/Controllers/Admin/StaffController.php:45
Issue / Evidence
paginate() is called after orderBy, better to confirm chaining correctness
Suggested Fix
ensure paginate is called last after all query builder modifications
Potential Null Or Empty Array Access On $R...
Where
app/Http/Controllers/Admin/StaffController.php:246
Issue / Evidence
potential null or empty array access on $request->shift_id[0]
Suggested Fix
add check if shift_id is an array and contains elements before accessing index 0
Missing Null Check For File Upload (Profil...
Where
app/Http/Controllers/Admin/StaffController.php:250
Issue / Evidence
missing null check for file upload (profile_image) before chaining and storing
Suggested Fix
add check for file presence to prevent errors
Missing Validation
Where
app/Http/Controllers/Admin/StaffController.php:257-289
Issue / Evidence
consider validation and sanitization of user inputs for children and dependents arrays
Suggested Fix
add validation rules and sanitize inputs before usage
Error Collection From Excel Import
Where
app/Http/Controllers/Admin/StaffController.php:88
Issue / Evidence
error collection from Excel import
Suggested Fix
consider logging details for debug purposes
Generic Exception Handling
Where
app/Http/Controllers/Admin/StaffController.php:105
Issue / Evidence
generic exception handling
Suggested Fix
consider specific exception handling to avoid masking errors
Message Construction Could Be Clearer And...
Where
app/Http/Controllers/Admin/StaffController.php:67-69
Issue / Evidence
message construction could be clearer and externalized for better localization
Suggested Fix
externalize user-facing messages and improve clarity
Code Change Preview · app/Http/Controllers/Admin/StaffController.php
?
Removed / Before Commit
- $query->where('department_id', $request->department_id); - } - - $staffs = $query->latest()->paginate(10)->appends($request->all()); // keep filters during pagination - - $employeeCategories = EmployeeCategory::where('is_active', 1)->get(); - $departments = Department::all(); - } - public function import(Request $request) - { - $request->validate([ - 'file' => 'required|mimes:xlsx,xls,csv' - ]); - - Excel::import(new StaffImport, $request->file('file')); - - return response()->json(['message' => 'Staff data imported successfully']); - }
Added / After Commit
+ $query->where('department_id', $request->department_id); + } + + // $staffs = $query->paginate(10)->appends($request->all())->orderBy('employee_number', 'asc')->get(); // keep filters during pagination + + $staffs = $query + ->orderBy('employee_number', 'asc') + ->paginate(10) + ->appends($request->all()); // keep filters during pagination + + $employeeCategories = EmployeeCategory::where('is_active', 1)->get(); + $departments = Department::all(); + } + public function import(Request $request) + { + try { + $request->validate([ + 'file' => 'required|mimes:xlsx,xls,csv'
Removed / Before Commit
- \ No newline at end of file
Added / After Commit
+ <?php + + namespace App\Http\Controllers\Api; + + use Illuminate\Http\Request; + use App\Models\Attendance; + use Carbon\Carbon; + + class BiometricController extends Controller + { + + public function receive(Request $request) + { + // ✅ Step 1: request_code check + $requestCode = strtolower($request->header('request_code')); + + if ($requestCode !== 'realtime_glog') { + return response('', 200, [
Removed / Before Commit
- use App\Models\Group; - use App\Models\LeaveType; - use App\Models\Leave; - use Maatwebsite\Excel\Facades\Excel; - use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate; - - */ - public function index(Request $request) - { - $query = Attendance::query()->with('employee'); - - // Shift - if ($request->shift) { - */ - public function upload(Request $request) - { - $request->validate([ - 'attendance_file' => 'required|mimes:xlsx,xls'
Added / After Commit
+ use App\Models\Group; + use App\Models\LeaveType; + use App\Models\Leave; + use App\Services\LeaveValidationService; + use Maatwebsite\Excel\Facades\Excel; + use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate; + + */ + public function index(Request $request) + { + $query = Attendance::query() + ->with([ + 'employee', + 'leave', + 'leave.leaveType' + ]); + +
Removed / Before Commit
- \ No newline at end of file
Added / After Commit
+ <?php + + namespace App\Http\Controllers; + + use Illuminate\Http\Request; + use App\Models\Attendance; + use Carbon\Carbon; + use Illuminate\Support\Facades\Log; + use App\Models\BiometricAttendance; + use Illuminate\Support\Facades\Validator; + use Illuminate\Http\JsonResponse; + + class BiometricController extends Controller + { + + + public function receive(Request $request) + {
Removed / Before Commit
- { - public function index() - { - // Show all complaints regardless of status (resolved, not resolved, null user status) - $complaints = Complaint::with(['resolver', 'assignedBy', 'assignedTo', 'natureOfComplaint']) - ->orderBy('created_at', 'desc') - ->paginate(10); - - - - return view('complaints.index', compact('complaints')); - } - - public function create() - { - $natureOptions = NatureOfComplaint::where('status', true)->orderBy('created_at', 'desc')->get(); - - public function store(Request $request)
Added / After Commit
+ { + public function index() + { + // Get current user + $currentUser = Auth::user(); + + // Start building the query for complaints + $complaintsQuery = Complaint::with(['resolver', 'assignedBy', 'assignedTo', 'natureOfComplaint']); + + // Check if user is admin (role = null or empty) or regular user (role != null) + if ($currentUser->role != null && $currentUser->role != '') { + // Regular user - filter by their group_id + $complaintsQuery->where('group_id', $currentUser->group_id); + } + // If role is null or empty (admin), show all complaints - no additional filtering needed + + // Show complaints with pagination + $complaints = $complaintsQuery->orderBy('created_at', 'desc')->paginate(10);
Removed / Before Commit
- ->latest() - ->first(); - - if ($pendingEntry) { - return redirect()->back() - ->with('error', 'Please complete issuing for the previous CRC entry before creating a new one because job no pending.'); - } - - $units = Unit::select('id', 'name')->get(); - $commands = MasterCommand::select('id', 'name')->get();
Added / After Commit
+ ->latest() + ->first(); + + // if ($pendingEntry) { + // return redirect()->back() + // ->with('error', 'Please complete issuing for the previous CRC entry before creating a new one because job no pending.'); + // } + + $units = Unit::select('id', 'name')->get(); + $commands = MasterCommand::select('id', 'name')->get();
Removed / Before Commit
- - use Illuminate\Http\Request; - use App\Models\CrcPartMaster; - - class CrcPartMasterController extends Controller - { - public function index() - { - $records = CrcPartMaster::latest()->get(); - return view('crc_part_master.index', compact('records')); - } - - public function store(Request $request)
Added / After Commit
+ + use Illuminate\Http\Request; + use App\Models\CrcPartMaster; + use App\Models\Equipment; + + class CrcPartMasterController extends Controller + { + public function index() + { + $records = CrcPartMaster::latest()->get(); + $equipments =Equipment::all(); + return view('crc_part_master.index', compact('records','equipments')); + } + + public function store(Request $request)
Removed / Before Commit
- ->endOfDay(); - - // Total quantity (created_at based) - $totalQuery = WorkEquipment::whereBetween('created_at', [$monthStart, $monthEnd]); - $totalQuantity = $totalQuery->count(); - - // Out quantity (wcn_date based) - $groupCounts = []; - - foreach ($outEquipments as $equipment) { - if ($equipment->group) { - $groupName = $equipment->group->name; - $groupCounts[$groupName] = ($groupCounts[$groupName] ?? 0) + 1; - } - } - - /** - * Step 3:
Added / After Commit
+ ->endOfDay(); + + // Total quantity (created_at based) + $totalQuery = WorkEquipment::wherenull('work_equipment_id')->whereBetween('created_at', [$monthStart, $monthEnd]); + $totalQuantity = $totalQuery->count(); + + // Out quantity (wcn_date based) + $groupCounts = []; + + foreach ($outEquipments as $equipment) { + + if ($equipment->group) { + + $groupName = $equipment->group->name; + + // agar work_equipment_id null nahi hai to qty add karo + if (!is_null($equipment->work_equipment_id)) { +
Removed / Before Commit
- use App\Models\InventoryCart; - use App\Models\Receive; - use DB; - - class InventoryController extends Controller - { - public function index(Request $request) - { - $query = McoDemand::select('mco_demands.mco_demand_no') - ->whereNotNull('mco_demand_no') - ->join('mco_admin_demand_approvals as approvals', 'mco_demands.req_no', '=', 'approvals.req_no') - ->groupBy('mco_demands.mco_demand_no') - ->orderby('mco_demands.mco_demand_no'); - - // Filter by date range if provided - if ($request->filled('date')) { - // Expecting format: YYYY-MM-DD - YYYY-MM-DD - [$start, $end] = explode(' - ', $request->date);
Added / After Commit
+ use App\Models\InventoryCart; + use App\Models\Receive; + use DB; + use App\Models\ProductionYear; + + class InventoryController extends Controller + { + public function index(Request $request) + { + $activeYear = ProductionYear::where('is_active', 1) + ->value('financial_year'); + + /* + |-------------------------------------------------------------------------- + | 2. Selected Production Year + |-------------------------------------------------------------------------- + */ + if (!empty($request->year)) {
Removed / Before Commit
- use App\Models\Receive; - use App\Models\Issue; - use App\Models\WorkEquipment; - - class IssueController extends Controller - { - // Show unique regn_no groups - public function index(Request $request) - { - $query = Receive::query(); - - if ($request->filled('job_no')) { - $query->where('job_no', $request->job_no); - } - if ($request->filled('equipment_id')) { - $query->where('work_equipment_id', $request->equipment_id); - } - if ($request->filled('voucher_no')) {
Added / After Commit
+ use App\Models\Receive; + use App\Models\Issue; + use App\Models\WorkEquipment; + use App\Models\ProductionYear; + + class IssueController extends Controller + { + // Show unique regn_no groups + public function index(Request $request) + { + // Active year + $activeYear = ProductionYear::where('is_active', 1)->first(); + + $selectedYear = $request->filled('prod_year') + ? $request->prod_year + : ($activeYear->financial_year ?? null); + + /*
Removed / Before Commit
- - use Illuminate\Http\Request; - use App\Models\Leave; - - class LeaveApprovalController extends Controller - { - - return back()->with('error', 'Leave rejected.'); - } - }
Added / After Commit
+ + use Illuminate\Http\Request; + use App\Models\Leave; + use App\Models\Staff; + use App\Models\LeaveType; + + class LeaveApprovalController extends Controller + { + + return back()->with('error', 'Leave rejected.'); + } + + public function appliedLeaves() + { + return view('leave.applied-leaves'); + } + + public function appliedLeavesList(Request $request)
Removed / Before Commit
- - $assignedLeaveTypes = $employee->designation->leaveTypes ?? []; - - $leaves = Leave::with('leaveType')->where('employee_id', $employee->id)->orderBy('from_date', 'desc')->paginate(20); - - $leaveBalance = [];
Added / After Commit
+ + $assignedLeaveTypes = $employee->designation->leaveTypes ?? []; + + $leaves = Leave::with('leaveType')->where('employee_id', optional($employee)->id)->orderBy('from_date', 'desc')->paginate(20); + + $leaveBalance = [];
Removed / Before Commit
- $query->where('leave_category', $request->leave_category); - } - - if ($request->filled('eligible_for')) { - $query->where('eligible_for', $request->eligible_for); - }
Added / After Commit
+ $query->where('leave_category', $request->leave_category); + } + + if ($request->filled('leave_category')) { + $query->where('leave_category', $request->leave_category); + } + + if ($request->filled('eligible_for')) { + $query->where('eligible_for', $request->eligible_for); + }
Removed / Before Commit
- - use App\Models\McoAdminDemandApproval; - use App\Models\McoDemand; - use Illuminate\Http\Request; - use Illuminate\Support\Facades\Crypt; - use App\Models\ProductionYear; - use DB; - - class McoAdminDemandApprovalController extends Controller - { - public function index(Request $request) - { - // Base query for demands - $query = McoDemand::with(['workEquipment.Equipments']) - ->select('work_equipment_id', 'job_no', 'req_no') - ->where('status', 'approved') - ->whereIn('req_no', function ($q) { - $q->select('req_no')->from('mco_submissions');
Added / After Commit
+ + use App\Models\McoAdminDemandApproval; + use App\Models\McoDemand; + use App\Models\WorkEquipment; + use Illuminate\Http\Request; + use Illuminate\Support\Facades\Crypt; + use App\Models\ProductionYear; + use DB; + + class McoAdminDemandApprovalController extends Controller + { + // public function index(Request $request) + // { + // // Base query for demands + // $query = McoDemand::with(['workEquipment.Equipments']) + // ->select('work_equipment_id', 'job_no', 'req_no', 'prod_year') + // ->where('status', 'approved') +
Removed / Before Commit
- use Illuminate\Http\Request; - use App\Models\McoSubmission; - use App\Models\WorkEquipment; - - class McoDemandController extends Controller - { - public function index(Request $request) - { - $query = McoDemand::select('work_equipment_id', 'job_no', 'req_no','created_at') - ->where('status', 'approved'); - - // Apply filters - if ($request->filled('job_no')) { - $query->where('job_no', $request->job_no); - } - - if ($request->filled('equipment_id')) { - $query->where('work_equipment_id', $request->equipment_id);
Added / After Commit
+ use Illuminate\Http\Request; + use App\Models\McoSubmission; + use App\Models\WorkEquipment; + use DB; + + class McoDemandController extends Controller + { + // public function index(Request $request) + // { + // $query = McoDemand::select( + // 'req_no', + // 'work_equipment_id', + // 'job_no', + // 'prod_year', + // DB::raw('MAX(created_at) as created_at'), + // DB::raw('GROUP_CONCAT(DISTINCT mco_demand_no ORDER BY CAST(mco_demand_no AS UNSIGNED)) as demand_nos') + // ) + // ->where('status', 'approved');
Removed / Before Commit
- { - $request->validate([ - 'no_of_items' => 'nullable|integer', - ]); - - $scale->update($request->only([ - return Excel::download(new McoScaleDataExport($tableName), $fileName); - } - - public function showData(McoScale $scale, Request $request) - { - $table = $scale->table_name; - - if (!Schema::hasTable($table)) { - return redirect()->back()->withErrors('Table does not exist.'); - } - - // Columns
Added / After Commit
+ { + $request->validate([ + 'no_of_items' => 'nullable|integer', + 'scale_name' => 'required', + 'scale_ref_auth' => 'required|string', + ]); + + $scale->update($request->only([ + return Excel::download(new McoScaleDataExport($tableName), $fileName); + } + + public function showData(McoScale $scale, Request $request) + { + $table = $scale->table_name; + + if (!Schema::hasTable($table)) { + return redirect()->back()->withErrors('Table does not exist.'); + }
Removed / Before Commit
- { - $selectedJob = $request->get('job_no'); - - // Only those job_no where at least one MRWorkEquipment's qty is still pending in mandr - $jobNumbers = WorkOrder::whereNull('control_no') - ->whereHas('mrWorkEquipments', function ($query) { - $query->whereRaw('( - SELECT COALESCE(SUM(quantity), 0) - FROM mandr - WHERE mandr.equipment_id = mr_work_equipments.id - ) < mr_work_equipments.quantity'); - }) - ->pluck('job_no'); - - // Same logic for listing MRWorkEquipments - $equipments = MrWorkEquipment::whereHas('workOrder', function ($q) use ($selectedJob) { - $q->whereNull('control_no'); -
Added / After Commit
+ { + $selectedJob = $request->get('job_no'); + + // Only M&R Job Numbers + $jobNumbers = WorkOrder::whereNull('control_no') + ->where('job_no', 'like', 'M&R/%') + ->pluck('job_no'); + + // Get Equipments (Nothing hidden) + $equipments = WorkEquipment::whereHas('workOrder', function ($q) use ($selectedJob) { + + $q->whereNull('control_no') + ->where('job_no', 'like', 'M&R/%'); + + if ($selectedJob) { + $q->where('job_no', $selectedJob); + } + })
Removed / Before Commit
Added / After Commit
+ <?php + + namespace App\Http\Controllers; + use Illuminate\Support\Facades\DB; + use Illuminate\Http\Request; + use App\Models\{ + Unit, Wksp, Bde, Div, Co, Corp, MasterCommand, + RepairClass, Group, Equipment, SubAssyEquipment, + WorkUser, WorkUnit, WorkOrder, WorkEquipment,VIR, + QADecision,QCCheck,EquipmentRepair,QaInspectionInitate, + QAInspection,QCInspection,GatePass,GatePassDetail + }; + use Carbon\Carbon; + use Illuminate\Support\Facades\Auth; + + class OldMRDataController extends Controller + { + public function movedata(Request $request)
Removed / Before Commit
- use App\Models\RepairClass; - use App\Models\McoScale; - use App\Models\DemandApproval; - use App\Models\Issue; - use App\Models\Receive; - use App\Models\Demand; - $q->where('name', 'CL A'); - }) - ->when(true, $applyGroupCondition) // 🔐 group filter - ->with('equipments') - ->select('main_eqpt') - ->distinct() - /** - * 📌 3. Base query — CL A + group wise - */ - $equipmentsQuery = WorkEquipment::whereNull('wcn_number') - ->whereHas('workOrder', function ($query) { - $query->whereNotNull('job_no')
Added / After Commit
+ use App\Models\RepairClass; + use App\Models\McoScale; + use App\Models\DemandApproval; + use App\Models\ProductionYear; + use App\Models\Issue; + use App\Models\Receive; + use App\Models\Demand; + $q->where('name', 'CL A'); + }) + ->when(true, $applyGroupCondition) // 🔐 group filter + ->where('status', '!=', 'VIR REJECTED') + ->with('equipments') + ->select('main_eqpt') + ->distinct() + /** + * 📌 3. Base query — CL A + group wise + */ + $equipmentsQuery = WorkEquipment::whereNull('wcn_number')->where('status', '!=', 'VIR REJECTED')
Removed / Before Commit
- use App\Models\WorkEquipment; - use App\Models\WorkOrder; - use App\Models\Vir; - use Auth; - - class QADecisionController extends Controller - - $equipment = WorkEquipment::find($request->work_equipment_id); - $equipment->status = 'AWAITING JOB NO'; - $equipment->save(); - - return redirect()->route('qa.index')->with('success', 'QA Decision saved.'); - }
Added / After Commit
+ use App\Models\WorkEquipment; + use App\Models\WorkOrder; + use App\Models\Vir; + use App\Models\QCCheck; + use Auth; + + class QADecisionController extends Controller + + $equipment = WorkEquipment::find($request->work_equipment_id); + $equipment->status = 'AWAITING JOB NO'; + $equipment->save(); + + $workorder = WorkOrder::with('equipment.group')->findOrFail($request->work_order_id); + $repairClass = $workorder?->equipment?->RepairClass?->name; + + // if (!in_array(strtoupper(trim((string) $repairClass)), ['DR', 'CL A'])) { + // QCCheck::create([ + // 'qc_control_no' =>$repairClass ?? 'repair class null',
Removed / Before Commit
- */ - $equipments = WorkEquipment::with([ - 'workOrder', - 'vir' ]) - - // 🔑 MAIN STATUS CONDITION - ->where('status', 'AWAITING QA INSPECTION')
Added / After Commit
+ */ + $equipments = WorkEquipment::with([ + 'workOrder', + 'vir','QaInspectionInitate' ]) + + // 🔑 MAIN STATUS CONDITION + ->where('status', 'AWAITING QA INSPECTION')
Removed / Before Commit
- 'vir', - 'workOrder.qcCheck' - ]) - ->whereIn('work_order_id', $workOrderIds->pluck('work_order_id')) - ->latest() - ->get() - 'remark' => $request->remark, - 'user_id' => Auth::id(), - ]); - WorkEquipment::where('work_order_id', $request->work_order_id)->update(['status' => 'UNDER REPAIR']); - } - - return redirect()->route('qc.index')->with('success', 'QC Check Saved Successfully');
Added / After Commit
+ 'vir', + 'workOrder.qcCheck' + ]) + ->where('status', '!=', 'VIR REJECTED') + ->whereIn('work_order_id', $workOrderIds->pluck('work_order_id')) + ->latest() + ->get() + 'remark' => $request->remark, + 'user_id' => Auth::id(), + ]); + WorkEquipment::where('work_order_id', $request->work_order_id)->where('status', '!=', 'VIR REJECTED')->update(['status' => 'UNDER REPAIR']); + } + + return redirect()->route('qc.index')->with('success', 'QC Check Saved Successfully');
Removed / Before Commit
- */ - $equipments = WorkEquipment::with([ - 'workOrder', - 'vir' ]) - - // 🔑 MAIN STATUS CONDITION - ->where('status', 'AWAITING QC INSPECTION')
Added / After Commit
+ */ + $equipments = WorkEquipment::with([ + 'workOrder', + 'vir','QaInspectionInitate' ]) + + // 🔑 MAIN STATUS CONDITION + ->where('status', 'AWAITING QC INSPECTION')
Removed / Before Commit
- /** - * Display a listing of the store inventory. - */ - public function index() - { - $inventories = StoreInventory::orderBy('created_at', 'desc')->paginate(10); - $groups = Group::pluck('name', 'id')->toArray(); - return view('store_inventory.index', compact('inventories', 'groups')); - } - - /** - * Show the form for creating a new store inventory item. - */ - // 'created_at' => $inventory->created_at->format('d-m-Y ') - // ]); - - return redirect()->route('store-inventory.index') - ->with('success', 'Store inventory item updated successfully RV Number' . $inventory->rv_number);
Added / After Commit
+ /** + * Display a listing of the store inventory. + */ + public function index(Request $request) + { + $query = StoreInventory::query(); + + // Apply filters + if ($request->filled('purchase_type')) { + $query->where('purchase_type', $request->purchase_type); + } + + if ($request->filled('group')) { + $query->where('group', $request->group); + } + + if ($request->filled('search')) { + $search = $request->search;
Removed / Before Commit
- return view('urgencies.lpr', compact('urgencyMaster', 'pendingItems', 'lprGroups','decryptedid')); - } - - // --- LPR Save --- - public function generateLpr(Request $request, $id) - {
Added / After Commit
+ return view('urgencies.lpr', compact('urgencyMaster', 'pendingItems', 'lprGroups','decryptedid')); + } + + public function printLpr($lprNos) + { + $lprNosArray = explode(',', $lprNos); + + // urgency items + $items = Urgency::with('urgencyMaster') + ->whereIn('lpr_no', $lprNosArray) + ->get(); + + // LPR No display + $lprNo = implode(', ', $lprNosArray); + + // header master (same urgency master for LPR) + $urgencyMaster = $items->first()?->urgencyMaster; +
Removed / Before Commit
- - public function jobCreateView(Request $request) - { - $workOrders = WorkOrder::with([ - 'workUnit', - 'workUser', - 'equipments.vir', - 'equipments.subassy' - ]) - - // 🔑 Sirf wahi WorkOrders jinke equipments me - // status = AWAITING JOB NO ho - ->when(!$request->filled('control_number'), function ($q) { - $q->whereHas('equipments', function ($q) { - $q->where('status', 'AWAITING JOB NO'); - }); - }) -
Added / After Commit
+ + public function jobCreateView(Request $request) + { + $workOrders = WorkOrder::with([ + 'workUnit', + 'workUser', + 'equipments', + 'equipments.vir', + 'equipments.subassy' + ]) + + // atleast ek equipment hona chahiye + ->whereHas('equipments') + + // ✅ sirf allowed status hone chahiye + ->whereDoesntHave('equipments', function ($q) { + $q->whereNotIn('status', [ + 'AWAITING JOB NO',
Removed / Before Commit
- ->values(); - - // 🔹 Always available - $committedData = WorkEquipment::whereNotNull('wcn_number') - ->where('status','UNDER WCN PROCESS') - ->with(['workOrder', 'qcInspection']) // optional eager loading - ->get(); - - $equipments = []; - - // 🔹 Equipments shown only after job_no filter - if ($request->filled('job_number')) { - - $job = WorkOrder::where('job_no', $request->job_number)->first(); - - if ($job) { - $equipments = $job->equipments() - // ->where('status', 'UNDER WCN PROCESS')
Added / After Commit
+ ->values(); + + // 🔹 Always available + $committedData = []; + + $equipments = []; + + // 🔹 Equipments shown only after job_no filter + if ($request->filled('job_number')) + { + + $job = WorkOrder::where('job_no', $request->job_number)->first(); + + if ($job) + { + $equipments = $job->equipments() + ->whereNull('wcn_number') // ✅ jinka wcn_number null hai + ->get();
Removed / Before Commit
- use Carbon\Carbon; - use App\Models\VIR; - use App\Models\ProductionYear; - - - class WorkOrderController extends Controller - ]); - } - - public function unit_detail($id) - { - return view('work-order.createunit', [ - $workUser = WorkUser::find($work_user_id); - } - - return view('work-order.createuser', compact('workUnit', 'workOrder', 'workUser')); - } -
Added / After Commit
+ use Carbon\Carbon; + use App\Models\VIR; + use App\Models\ProductionYear; + use App\Models\RepairClassCode; + + + class WorkOrderController extends Controller + ]); + } + + public function create(Request $request, $id = null) + { + $workOrder = null; + $workunit = null; + $workUser = null; + $equipment = null; + +
Removed / Before Commit
- namespace App\Imports; - - use App\Models\Staff; - use Maatwebsite\Excel\Concerns\ToModel; - use Maatwebsite\Excel\Concerns\WithHeadingRow; - use PhpOffice\PhpSpreadsheet\Shared\Date; - use Carbon\Carbon; - - class StaffImport implements ToModel, WithHeadingRow - { - public function model(array $row) - { - // Agar name ya employee_number nahi hoga toh skip - if (empty($row['name']) || empty($row['employee_number'])) { - return null; - } - - return new Staff([
Added / After Commit
+ namespace App\Imports; + + use App\Models\Staff; + use App\Models\Department; + use App\Models\Designation; + use App\Models\Shift; + use App\Models\EmployeeCategory; + use Maatwebsite\Excel\Concerns\ToModel; + use Maatwebsite\Excel\Concerns\WithHeadingRow; + use Maatwebsite\Excel\Concerns\WithEvents; + use Maatwebsite\Excel\Events\AfterImport; + use PhpOffice\PhpSpreadsheet\Shared\Date; + use Carbon\Carbon; + use Illuminate\Support\Facades\Log; + use Illuminate\Support\Collection; + + class StaffImport implements ToModel, WithHeadingRow, WithEvents + {
Removed / Before Commit
- { - return $this->belongsTo(Staff::class, 'employee_id'); - } - }
Added / After Commit
+ { + return $this->belongsTo(Staff::class, 'employee_id'); + } + + public function leave() + { + return $this->hasOne(Leave::class, 'attendance_id') + ->whereNotNull('attendance_id'); + } + + + }
Removed / Before Commit
Added / After Commit
+ <?php + + namespace App\Models; + + use Illuminate\Database\Eloquent\Factories\HasFactory; + use Illuminate\Database\Eloquent\Model; + + class BiometricAttendance extends Model + { + use HasFactory; + + protected $table = 'biometric_attendance'; + + protected $fillable = [ + 'employee_code', + 'log_datetime', + 'log_time', + 'device_sn',
Removed / Before Commit
- 'complaint_date', - 'complaint_time', - 'user_name', - 'group_id', - 'location', - 'nature_of_complaint', - 'complaint_description', - 'complaint_status', - 'admin_status', - 'admin_approval_remark', - 'approved_by', - 'approved_at', - 'user_remark',
Added / After Commit
+ 'complaint_date', + 'complaint_time', + 'user_name', + 'user_id', + 'group_id', + 'location', + 'nature_of_complaint', + 'complaint_description', + 'complaint_status', + 'admin_status', + 'admin_approval_remark', + 'approved_by', + 'approved_at', + 'user_remark',
Removed / Before Commit
- 'qty_demanded', - 'req_no', - 'registation_no', - 'status', - ];
Added / After Commit
+ 'qty_demanded', + 'req_no', + 'registation_no', + 'cos_sec', + 'status', + ];
Removed / Before Commit
- 'mco_demand_no', - 'job_no', - 'spares', - 'user_id', - ]; - protected $casts = [
Added / After Commit
+ 'mco_demand_no', + 'job_no', + 'spares', + 'prod_year', + 'user_id', + ]; + protected $casts = [
Removed / Before Commit
- class Issue extends Model - { - protected $table = 'issue'; - protected $fillable = ['item_id','scale_id','work_equipment_id','job_no','voucher_no', 'req_no','mco_demand_no', 'qty_issued','remark']; - }
Added / After Commit
+ class Issue extends Model + { + protected $table = 'issue'; + protected $fillable = ['item_id','scale_id','work_equipment_id','job_no','voucher_no', 'req_no','mco_demand_no', 'qty_issued','remark','prod_year']; + }
Removed / Before Commit
- use HasFactory; - - protected $fillable = [ - 'employee_id', - 'leave_type_id', - 'subject', - 'total_days', - 'description', - 'status', - ]; - - public function employee() { - public function leaveType() { - return $this->belongsTo(LeaveType::class, 'leave_type_id'); - } - }
Added / After Commit
+ use HasFactory; + + protected $fillable = [ + 'attendance_id', + 'employee_id', + 'leave_type_id', + 'subject', + 'total_days', + 'description', + 'status', + 'approval_status', + 'leave_type' + ]; + + public function employee() { + public function leaveType() { + return $this->belongsTo(LeaveType::class, 'leave_type_id'); + }
Removed / Before Commit
- - protected $fillable = [ - 'leave_name', - 'leave_category', - 'eligible_for', - 'leave_count', - 'carry_forward',
Added / After Commit
+ + protected $fillable = [ + 'leave_name', + 'leave_code', + 'leave_category', + 'leave_type', + 'eligible_for', + 'leave_count', + 'carry_forward',
Removed / Before Commit
- 'equipment_id', - 'job_no', - 'req_no', - 'remark', - 'submitted_at', - 'submitted_by',
Added / After Commit
+ 'equipment_id', + 'job_no', + 'req_no', + 'prod_year', + 'remark', + 'submitted_at', + 'submitted_by',
Removed / Before Commit
- { - return $this->hasOne(McoAdminDemandApproval::class, 'req_no', 'req_no'); - } - public function mcoSubmission() - { - return $this->hasOne(McoSubmission::class, 'req_no', 'req_no');
Added / After Commit
+ { + return $this->hasOne(McoAdminDemandApproval::class, 'req_no', 'req_no'); + } + + public function getDemandApprovalAttribute() + { + return McoAdminDemandApproval::where('req_no', $this->req_no) + ->where('prod_year', $this->prod_year) + ->first(); + } + public function mcoSubmission() + { + return $this->hasOne(McoSubmission::class, 'req_no', 'req_no');
Removed / Before Commit
- 'work_equipment_id', - 'job_no', - 'req_no', - 'remark', - 'submitted_by', - ];
Added / After Commit
+ 'work_equipment_id', + 'job_no', + 'req_no', + 'prod_year', + 'remark', + 'submitted_by', + ];
Removed / Before Commit
- - public function mrWorkEquipment() - { - return $this->belongsTo(MrWorkEquipment::class, 'equipment_id'); - } - public function qaInspectionInitiate() - {
Added / After Commit
+ + public function mrWorkEquipment() + { + return $this->belongsTo(WorkEquipment::class, 'equipment_id'); + } + public function qaInspectionInitiate() + {
Removed / Before Commit
- protected $table = 'staff'; - - protected $fillable = [ - // Profile & Personal Details - 'profile_image', 'name', 'employee_number','biometric','email', 'phone', 'allow_login', 'joining_date', 'status', 'address', - 'gender', 'dob', 'personal_email', 'personal_phone', 'is_married','employee_category_id', - - // Job Details - 'location_name', 'shift_id', 'department_id', 'designation_id','pan_card','aadhar_card', 'report_to', 'is_manager', - 'probation_start_date', 'probation_end_date', 'notice_start_date', 'notice_end_date', 'end_date', 'employee_status_id', - - // Salary Group Info - 'salary_group_id' - ]; - - // Automatically hash password - public function setPasswordAttribute($value) - {
Added / After Commit
+ protected $table = 'staff'; + + protected $fillable = [ + + // Profile & Personal + 'profile_image', + 'name', + 'employee_number', + 'biometric', + 'email', + 'phone', + 'allow_login', + 'joining_date', + 'status', + 'address', + 'gender', + 'dob', + 'personal_email',
Removed / Before Commit
- 'type', - 'created_at', - 'updated_at', - ]; - - public function workOrder() - { - return $this->hasOne(\App\Models\QAInspection::class, 'work_equipment_id'); - } - public function qcInspection() - { - return $this->hasOne(QCInspection::class, 'work_equipment_id');
Added / After Commit
+ 'type', + 'created_at', + 'updated_at', + 'work_equipment_id', + 'manufactured_quantity' + ]; + + public function workOrder() + { + return $this->hasOne(\App\Models\QAInspection::class, 'work_equipment_id'); + } + public function QaInspectionInitate() + { + return $this->hasOne(\App\Models\QaInspectionInitate::class, 'work_equipment_id'); + } + public function qcInspection() + { + return $this->hasOne(QCInspection::class, 'work_equipment_id');
Removed / Before Commit
- { - return $this->hasMany( - WorkEquipment::class, - 'work_order_id', // FK in work_equipment table - 'id' // PK in work_orders table - ); - } - - public function virs()
Added / After Commit
+ { + return $this->hasMany( + WorkEquipment::class, + 'work_order_id', + 'id' + )->where('status', '!=', 'VIR REJECTED'); + } + + public function virs()
Removed / Before Commit
Added / After Commit
+ <?php + + namespace App\Services; + + use App\Models\LeaveType; + use App\Models\Staff; + use App\Models\Leave; + use Carbon\Carbon; + + class LeaveValidationService + { + /** + * Validate if an employee can apply for a specific leave type + * + * @param Staff $employee + * @param LeaveType $leaveType + * @param string $startDate + * @param string $endDate
Removed / Before Commit
- \ No newline at end of file
Added / After Commit
+ <?php + + namespace App\Services; + + use App\Models\PayrollComponent; + use App\Models\ComponentLevelSlab; + + class SalaryCalculatorService + { + public function calculate($staff, $input = []) + { + $components = PayrollComponent::with('rule') + ->where('status', 1) + ->get(); + + $results = []; + $totalEarning = 0; + $totalDeduction = 0;
Removed / Before Commit
Added / After Commit
+ <?php + + use Illuminate\Database\Migrations\Migration; + use Illuminate\Database\Schema\Blueprint; + use Illuminate\Support\Facades\Schema; + + return new class extends Migration + { + /** + * Run the migrations. + */ + public function up(): void + { + Schema::table('leaves', function (Blueprint $table) { + $table->tinyInteger('leave_type')->default(0)->after('approval_status')->comment('0 = Present Leave, 1 = Past Leave'); + }); + } +