with()
function is used to eager load. Rather than using two or more separate queries for fetching the data from a database, you can use the with()
method after the first command. You will get a better user experience as you do not have to wait longer to fetch the data from the database.