Laravel get data based on foreign key
问题 So I have 2 tables, TABLE1 and TABLE2. They are linked throug Eloquent: TABLE1 has many TABLE2's, and TABLE2 has one TABLE 1. They are linked with foreign keys as such: in TABLE2 table1_id -> links to -> TABLE1 id. How do I retrieve the entire table data or TABLE 2, + replace table1_id with a column of table1 (let's say by booktitle for example)? Sorry for the abstraction, but this is the best way I can explain it? :D 回答1: The easiest way is to make use of Eloquent's eager loading and fetch