[Solved] Laravel Eloquent the same queries


In Either one of the code above, the query will just be 1

$a = Flight::find(1); is same as

select * from `flights` where `flights`.`id` = 1 limit 1`

Since $a & $b are 2 different variables, though they are calling the same Eloquent function, the queries are different. So the code above will result in 2 queries.

Also object created will be 2.

See here for more about Laravel Eloquent https://laravel.com/docs/8.x/eloquent

4

solved Laravel Eloquent the same queries