Hi. I am trying to use a variable where is outside of model query inside it as following codes but it doesn't work. Normally I can use it inside function by making global..
public function setPriority ($id) {
$affectingJob = Job::find($id);
$machine_id = 1;
$affectedJobQueue = Job::where([['state_id', 1],['user_id', Auth::user()->parent_user_id]])->with(['order' => function ($query) {
global $machine_id;
$query->where('machine_id', $machine_id);
}])->get()->min('queue');