Closures has there own local scope they dont see outer variables try using
function($query) use($dato)
{
}
Alright!, yes, scope issue is clear.one second let me try sorry I did not see your solution thank you
usm4n said:
Closures has there own local scope they dont see outer variables try using
function($query) use($dato) { }
I think whereRaw should be like this:
->whereRaw('id_specialty = ?', $dato);
that solved the scope issue! wonderful god bless you!; I though have syntax error at here
'id_specialty', '=', $dato)
unexpected T_VARIABLE
I have tried all possible combinations of the single quotes, to no result so far
Problem is in your whereRaw see my previous answer!
usm4n said:
I think whereRaw should be like this:
->whereRaw('id_specialty = ?', $dato);
:)
"Argument 2 passed to Illuminate\Database\Query\Builder::whereRaw() must be an array, string given,
but if I write "specialiation_id = 7'
it works, it works if I hardcode a digit there, and if I echo $dato is certainly is 7 why would not take $dato if it is equal to 7?
don't want to quote again :) already posted the solution try to scroll up this page :)
but I have copied and pasted the ->whereRaw('id_specialty = ?', $dato); when I said I had the syntax issue meant after pasting your whereinRaw
The second argument needs to be an array, just like the error message say.
->whereRaw('id_specialty = ?', [$dato]);
Sorry my bad :( try
->whereRaw('id_specialty = ?',array( $dato));
this should solve the problem.
Yes! it did and now, my god, how should I do both of you have been essential to the solution of the problem: Usm4m provided the critical use($dato) explaining that the closure have their own scope, and you solved the syntax. How can I give the solution to both ? You absolutely both deserve it.
Usm4n, both deserve it so we can do the following. I ll post whatever trivial question right now, you answer it and I upthumb it, we are not cheating both of you legitimately deserve it if the System is imperfect I have to bypass it. Shall we do that?
usm4n said:
:( beaten by @Marwelln with a 5 second difference trophy goes to him!
I give you the solution because your sytax was also correct but I absolutely want to give the solution to Marwell, so I will ask him if it is fine that I post whatever easy stuff and right away I will upthumb it. I just hate to be in the situation where two persons deserve the same merit and they limit me to one, it is not fair, so it needs to be bypassed.
Gotta watch Arrow season 2... We'll do it some other time, kuddos to @Marwelln he won, no worries i am happy you found your solution. Regards!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community