Laravel 6 ORM Time-out

  laravel, php

I have a problem when I loop the data, it will show 504 Gateway Time-out.

Timesheets table : 15,000 records

Employees Table: 400 records

Manpower Table: 100, 000 records.

If I get 3 tables in SQL just take 0.1ms. Any other solution for my case? Thanks All.

<?php
$timesheets = Timesheets::where('type', 'Overtime')
    ->get();

foreach ($timesheets as $key => $value) {
    if (!empty($employeesUuid = Employees::where('employees_number', $value->employees_id)->first()->employees_uuid)) {
        $date          = Carbon::parse($value->start_dt)->format('Y-m-d');

        $manpower = Manpower::with('pwra.purchaseOrder')
            ->where("employees_uuid", $employeesUuid)
            ->whereDate("register_date", $date)
            ->first();
    }
}

Source: Ask PHP

LEAVE A COMMENT