I have been using documentation successfully with when statements described here:
https://www.laravel.com/docs/5.2/queries#conditional-statements
I have four conditional statements like this one in my model which have all been working:
->when($qData['zip'], function ($query2) use ($qData) {
$query2->where('rentals.zip', '=', $qData['zip']);
})
On Thu, Jun 9 I added a new service called Entrust by Zizaco to handle user permissions. I updated Laravel after adding the new service in my composer.json file. Now I am getting this error message on my conditional statements:
FatalErrorException in Rental.php line 101:
Call to a member function when() on null
If all four of my select variables are empty, the query still works. If any one of the variables which are zip, beds, min and max are selected, the error message above appears.
The new service mentioned above is not used at all in the query. The only change is now I am running Laravel /Frameword v5.2.37
I am stumped as to why this stopped working. Documentation says when condition does not execute if the first statement is false.