I just want to make a where clause from string as my where clause depends upon the other variable. I did like this
$where_condition = "post_flight_informations.schedule_year,=,2022";
and then applied to query like this
->where($where_condition)
but it is taking $where_condition as a single argument so i have a Missing argument 2
error can someone help me on this thank you
5
Answers
Thank you all finally i solved it like this
and
Well in that case, you should make your variable to be like this :
and the apply your query
where
condition used two arguments.On the laravel docs you should put a 3 arguments in
where
method to query.In your question you are passing a single argument. This is the correct way to use
where
method to addwhere
in to your query.The first argument is name of the column. Second argument is operator. Third is value to compare in the column value.
I would suggest you to use whereRaw
like the following example
then use this variable with