Laravel Query Builder join doesn't affect query <p>I'm trying to build in search functionality in my application (Laravel 5.1), but my join doesn't seem to do anything to the resulting query. What am I doing wrong?</p> <p>Code:</p> <pre><code>$query = InvoiceHeader::where('customer_code_id', '=', Auth::user()-&gt;customer_code_id); $query-&gt;join('invoice_types', 'invoice_headers.invoice_type_id', '=', 'invoice_types.id') -&gt;where('invoice_types.name', '&lt;&gt;', array_search('Faktura', InvoiceHeader::INVOICE_TYPES)); $invoices = $query-&gt;paginate(15); </code></pre> <p>Resulting query:</p> <blockquote> <p>select count(*) as aggregate from <code>invoice_headers</code> where <code>customer_code_id</code> = 1 and (<code>invoice_types</code>.<code>name</code> &lt;> 380)</p> </blockquote> <p>Resulting response:</p> <blockquote> <p>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'invoice_types.name' in 'where clause'</p> </blockquote> <p>This is the query I was hoping to see:</p> <pre><code>select count(*) as aggregate from invoice_headers inner join invoice_types on invoice_headers.invoice_type_id = invoice_types.id where customer_code_id = 1 and (invoice_types.name &lt;&gt; 380) </code></pre>