title: Laravel changing the inner join via user input
body: <p>My Plan is the following. 
  I have this inner join:</p>
  
  <pre><code>SELECT cd.fk_lend_id,cd.serialnumber ,customers.name,cd.created_at
  FROM cd
  INNER JOIN customers ON cd.fk_lend_id = customer.lend_id
  Where cd.fk_lend_id = 00000000;
  </code></pre>
  
  <p>This is what it would look like in Laravel:</p>
  
  <pre><code>$scores = DB::table('cd')
  -&gt;join('cd', 'cd.fk_lend_id', '=', 'customer.lend_id')
  -&gt;select('cd.fk_lend_id','cd.serialnumber','users.name', 'cd.created_at')
  -&gt;where('cd.fk_lend_id',00000000)
  -&gt;get();
  </code></pre>
  
  <p>(The created_at stands for the time the customer lend the cd)</p>
  
  <p>->where('cd.fk_lend_id',00000000) &lt;- The zero´s should be replaced with the user input from the inputfield from the view and after the input it should be redirected is this possible?</p>
  
  <p>If it is possible does anyone can give me advice how to do so?</p>
  
  <p>(Edit)</p>
  
  <p>The "yourcds" function:</p>
  
  <pre><code>public function yourcds(Request $request, cds $cd)
  {
      $this-&gt;middleware('guest');
  
      $user_input = $request-&gt;userInput
      $scores = DB::table('cd')
      -&gt;join('customers', 'cd.fk_lend_id', '=', 'customer .lend_id')
      -&gt;select('cd.fk_lend_id','cd.serialnumber','users.name', 'cd.created_at')
      -&gt;where('cd.fk_lend_id',$request-&gt;$user_input)
      -&gt;get();
  
      $cds = cd::latest()-&gt;paginate(20);
  
      return view('cd.yourcds',compact('cd'))
          -&gt; with('i', (request()-&gt;input('page', 1) - 1) * 20);
  }
  </code></pre>
  
  <p>The "return" function:</p>
  
  <pre><code>    public function return(cds $cd)
  {
  
    return view('cd.return',compact('cd'));
  }
  </code></pre>