title: Laravel finding where two tables have matching values and displaying both to the view
body: <p>Ok so the two tables are for a customer and a job associated with that customer. Both of the tables (jobs,customers) have location ids that links the two. In the view I am displaying all the jobs in a table which also includes that customers address. I have tried in the controller but it is saying &quot;Property [location_number] does not exist on the Eloquent builder instance.&quot;. This is my Controller Method:</p>
  <pre><code>public function search_job(Request $request){
  
  
  
      if($request-&gt;class == '' &amp;&amp; $request-&gt;status == '' &amp;&amp; $request-&gt;type == '' &amp;&amp; $request-&gt;department == '' &amp;&amp; $request-&gt;start_date == '' &amp;&amp; $request-&gt;end_date == '' &amp;&amp; $request-&gt;last_called == '')
      {
          $jobs = Job::where('class','LIKE','%'.&quot;none&quot;.'%');
          // return view('callCenter.ccJobSearch' ,['jobs'=&gt;$jobs]);
          $custs = Customer::where('location_number',$jobs-&gt;location_number)-&gt;get();
  
          return view('callCenter.ccJobSearch',['jobs'=&gt;$jobs,'custs'=&gt;$custs]);
      }
      else
      {
          if($request-&gt;start_date ==NULL)
          {
              $request-&gt;start_date = date(&quot;01-01-1970&quot;);
          }
          if($request-&gt;end_date ==NULL)
          {
              $request-&gt;end_date = date(&quot;m-d-Y&quot;);
          }
          if($request-&gt;last_called ==NULL)
          {
              $request-&gt;last_called = date(&quot;m-d-Y&quot;);
          }
  
          $jobs = Job::where('class','LIKE','%'.$request-&gt;class.'%')
                      -&gt;where('job_status','LIKE','%'.$request-&gt;status.'%')
                      -&gt;where('type','LIKE','%'.$request-&gt;type.'%')
                      -&gt;where('department','LIKE','%'.$request-&gt;department.'%')
                      -&gt;whereBetween('date_booked',[$request-&gt;start_date, $request-&gt;end_date])
                      -&gt;whereBetween('date_last_called',['01-01-1970',$request-&gt;last_called])-&gt;get();
  
          $custs = Customer::where('location_number',$jobs-&gt;location_number)-&gt;get();
  
          return view('callCenter.ccJobSearch',['jobs'=&gt;$jobs,'custs'=&gt;$custs]);
      }
      
  
  
  }
  </code></pre>
  <p>and this the part of my view where I try to access those arrays:</p>
  <pre><code>                                @foreach($jobs as $job)
                                  &lt;tr class=&quot;bg-white lg:hover:bg-gray-100 flex lg:table-row flex-row lg:flex-row flex-wrap lg:flex-no-wrap mb-10 lg:mb-0&quot;&gt;
                           
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          &lt;div class=&quot;flex items-center&quot;&gt;
                                              &lt;div class=&quot;ml-4&quot;&gt;
                                                  &lt;div class=&quot;text-sm font-medium text-gray-900&quot;&gt;
                                                      {{$job-&gt;job_number}}
                                                      
                                                  &lt;/div&gt;
                                      
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;type}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;department}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;billing_number}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;location_number}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$cust-&gt;last_name}}
                                      
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;date_booked}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;job_status}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;tech}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;class}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$custs-&gt;street_address}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$custs-&gt;city}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$custs-&gt;state}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$custs-&gt;zip}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$custs-&gt;phone_number_1}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;happy_check_by}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;type}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;span class=&quot;lg:hidden absolute top-0 left-0 bg-blue-200 px-dispatch.2 py-1 text-xs font-bold uppercase&quot;&gt;&lt;/span&gt;
                                          {{$job-&gt;type}}
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;button class=&quot;text-gray-500 bg-yellow-200 border border-solid border-gray-500 hover:bg-yellow-400 hover:text-white active:bg-pink-600 font-bold uppercase text-base px-2 py-1 rounded outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150&quot; type=&quot;button&quot;&gt;
                                              &lt;i class=&quot;far fa-sticky-note&quot;&gt;&lt;/i&gt;
                                          &lt;/button&gt;
                                      &lt;/td&gt;
                                      &lt;td class=&quot;w-full lg:w-auto p-1 text-gray-800 text-center border border-b block lg:table-cell relative lg:static text-xs&quot;&gt;
                                          &lt;button class=&quot;text-white bg-blue-300 border border-solid border-gray-500 hover:bg-blue-500 hover:text-white active:bg-pink-600 font-bold uppercase text-xs px-4 py-2 rounded outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150&quot; type=&quot;button&quot;  onclick=&quot;window.open('http://localhost:8000/callCenter/ccJobInfo');&quot;&gt;
                                              Info
                                          &lt;/button&gt;
                                      &lt;/td&gt;
                                      
                                  &lt;/tr&gt;
                                  @endforeach
  </code></pre>