Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Eloquent Query -> Undefined Variable

Attached is a screenshot of the error I am facing. I have the log show the value of the $team variable. What am I doing wrong? enter image description here

like image 221
Vishnoo Rath Avatar asked Dec 08 '22 14:12

Vishnoo Rath


1 Answers

You don't have access to parents variables from a closure, you need to explicitly send variables to the closure with use keyword

function($query) use ($team)
like image 198
vadim savin Avatar answered Dec 11 '22 12:12

vadim savin