0
$bookingd = Booking::where('status', '!=', 'assigned')
                    ->whereIn('mechanic_id', $mechids)
                    ->whereDate('created_at', 'not like', Carbon::now()->format('Y-m-d'));
                    
if($userid!='')
    $bookingd->where('mechanic_id', '!=', $userid);

$bookingd->groupBy('mechanic_id')->pluck('mechanic_id');
print_r($bookingd, true);

When i enable query log, get the command select mechanic_id from bookings where status != 'assigned' and mechanic_id in (14,15,110,120,121,123,124,126,127,128,129,130) and date(created_at) not like '2021-06-18' GROUP BY mechanic_id

which in return

enter image description here

1 Answers1

0

Add this at the very top your code of PHP ini_set("memory_limit", "2048M"); in your PHP script. Make sure to increase memory_limit according to your need.

If you keep on getting this kind of error message of exhausted memory. you can use ini_set("memory_limit", "-1");. This will set your memory limit to no limit.

Note: This will set your memory limit to no limit. Memory limit is the thing which is dependent on your OS and RAM not on PHP.

Note: Also please make sure if you are doing something on your production environment in your PHP script, whose job is to keep on adding data to there script, either in your static variables(Example: gathering multiple CSV's data) or some arrays, then it can lead to either failure of that VM or PHP process in case of complete memory exhaust. Reference

Arjun bhati
  • 306
  • 1
  • 3
  • 12