Q:

Eager loading a related table

I have three models:
 - Transaction (ab_transactions)
 - Order (ab_orders)
 - Customer (ab_customers)
I'm trying to get all transactions for a specific month, which is easy enough:
Transaction::whereYear('TransDate', '=', '2017')->whereYear('TransDate', '=', '08')->get();

This returns all transactions from August 2017. The ab_transactions table has a column "OrderNumber", which links it to the primary key "OrderNumber" in ab_orders.
This is my Transaction.php model
public function order() {
    return $this->belongsTo('App\Order', 'OrderNumber', 'OrderNumber');
}

I need to be able to select only transactions where the related ab_orders.Product is "example". I've tried doing this using a join, which works, but I also need to eager load the data, for the related tables ab_customers and ab_orders.
Is this possible? I'm using Laravel 5.2 (can't upgrade yet), and aware that my naming conventions aren't ideal - unfortunately this table is used by a legacy system that can't be changed.

A:

I ended up finding a section in the Laravel docs, which answered my question. Here's their snippet, which does exactly what I needed.
$books = App\Book::with('author.contacts')->get();

