eloquent modifying variable without overwriting

120

Question: eloquent modifying variable without overwriting

I have been trying to perform some queries using a set variable with models inside it

so what I'm trying to do is something like this

$orders = (new Order)->where('placed_by', '=', "client"); 

if you die and dump this the outcome would be as expected now

let's find something specific

$totalPrice = $orders->where('total_price', '=', "100"); 

and then find something else

$totalPrice = $orders->where('total_price', '=', "10"); 

what you would think that the $orders variable contents would stay static but it doesn't it changes now is there a way to keep it as is without php error it changing because of the next operations?

Total Answers: 1

6

Answers 1: of eloquent modifying variable without overwriting

mofiroz suggested in a comment :

you can use clone provided by laravel.

which works.