K
K
Konstantin2018-11-15 03:47:48
Laravel
Konstantin, 2018-11-15 03:47:48

When to use lazy Loading and Eager Loading in Laravel?

Can you please explain when to use lazy Loading and Eager Loading in Laravel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NXLLIFIER, 2018-11-16
@NXLLIFIER

lazy loading is used by default, when you access some kind of connection through a model object, then when you request this connection, a request to the database will be executed.
Eager loading is used when they know for sure that connections will be needed and the necessary connections are indicated in the request of the model from which they need to be obtained.
In this case, your object will already have model objects from the links that you specify in with ().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question