I have this function in php (laravel):
public static function isUserParticipatesInTournament($tourId, $userId)
{
var_dump($userId); //dumped
Your $tourId
variable is not in the scope of your anonymous function. Have a look at the use
keyword to see how you can add it to the scope. See example 3 on this page: http://www.php.net//manual/en/functions.anonymous.php
It should look something like the following:
$obj = $user->whereHas('tournaments', function($query) use($tourId)
{
var_dump($tourId); // Dumps OK
})->get();