Now that you have learned how to define your relationships, I think you are ready to learn how to query them. Let's start with a very basic example.
Let's suppose that we are searching for the document number of a specific user. We will use the
IdentityDocument entities we just saw. For the purpose of this example, imagine that you have a table
identitydocuments with the following columns:
Number: This indicates the document number
Type: This indicates the document type
due_date: This indicates the due date of the document
City: This indicates the city where the document was released
Here's the code to get the document identity number, starting from a
$user = \App\User::where('first_name', '=', 'Francesco')->where('last_name', ...