Index Scopes

If you are ordering or searching by fields on a related table, you will need to add a join to the index query.

You can add this join for every query:

->setJoinsCallback(function ($query) {
    return $query
        ->select('things.*', 'stuffs.name as stuff_name')
        ->leftJoin('stuffs', 'things.stuff_id', '=', 'stuffs.id');
})

Or only on queries that include a search term:

->setSearchJoinsCallback(function ($query) {
    return $query->join('stuffs', 'things.stuff_id', '=', 'stuffs.id');
})

Or only on queries that are ordered:

->setOrderColumnScopes([
    'my_orderable_column' => function ($query) {
        return $query->join('stuffs', 'things.stuff_id', '=', 'stuffs.id');
    },

The first option is less efficient but using the second two can cause conflicts if, for example, seaching AND ordering at the same time.