title: How to send parameters from datatable to controller Laravel
body: <p>I have a datatable in my blade view Laravel, I user click the blue button it will open new page and show all task with same user_id as clicked  before</p>
  <p><a href="https://i.stack.imgur.com/J7tWS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J7tWS.png" alt="enter image description here" /></a></p>
  <p>I'm trying to pass <code>user_id</code> value to controller. I have do this following code</p>
  <p>My routes</p>
  <pre><code> Route::get('/detail/{user_id}', [PageController::class, 'UserTask'])-&gt;name('user.task');
  </code></pre>
  <p>My datatable code in blade file</p>
  <pre><code> $(function() {
          var user_id = $(this).data('user_id'); //have different value from each rows
          $.ajaxSetup({
              headers: {
                  'X-CSRF-TOKEN': $('meta[name=&quot;csrf-token&quot;]').attr('content')
              }
          });
  
          var table = $('.data-table').DataTable({
              processing: true,
              serverSide: true,
              ajax: &quot;{{ route('user.task') }}&quot; + '/' + user_id,
  
              columns: [{
                      data: 'DT_RowIndex',
                      name: 'DT_RowIndex',
                      orderable: false,
                      searchable: false,
                  },
                  {
                      data: 'title',
                      name: 'title',
                      orderable: false,
                  },
                  {
                      data: 'content',
                      name: 'content',
                      orderable: false,
                      visible: false,
                  },
                  {
                      data: 'progress',
                      name: 'progress'
                  },
                  {
                      data: 'status',
                      name: 'status'
                  },
                  {
                      data: 'target_selesai',
                      name: 'target_selesai'
                  },
                  {
                      data: 'action',
                      name: 'action',
                      orderable: false,
                      searchable: false
                  },
              ]
          });
      });
  </code></pre>
  <p>my controller</p>
  <pre><code>  public function UserTask($user_id)
      {
  
  
          $data = Post::where('user_id', $user_id)-&gt;latest()-&gt;get();
          return Datatables::of($data)
              -&gt;addIndexColumn()
              -&gt;addColumn('action', function ($row) {
                  $id = $row-&gt;id;
                  // $this-&gt;actionButton($row-&gt;id);
                  $btn = ' &lt;a href=&quot;javascript:void(0)&quot; data-toggle=&quot;tooltip&quot;  data-id=&quot;' . $id . '&quot; data-original-title=&quot;Detail&quot; class=&quot;btn btn-success mr-1 btn-sm detailProduct&quot;&gt;&lt;span class=&quot;fas fa-info&quot;&gt;&lt;/span&gt;&lt;/a&gt;';
  
                  return $btn;
              })-&gt;addColumn('target_selesai', function ($row) {
                  //...
              })
              -&gt;addColumn('progress', function ($row) {
                  //...
              })-&gt;addColumn('status', function ($row) {
                 //...
              })
              -&gt;rawColumns(['action', 'progress', 'status'])
              -&gt;make(true);
  
  
          return view('detail');
      }
  </code></pre>
  <p>But, it will return error <code>Missing required parameter for [Route: user.task]</code>
  If I remove all the parameter {user_id}, from routes, ajax routes, and change the</p>
  <pre><code> public function UserTask($user_id)
      {
          $data = Post::where('user_id', $user_id)-&gt;latest()-&gt;get();
  </code></pre>
  <p>into</p>
  <pre><code>public function UserTask()
      {
          $data = Post::where('user_id', 1000000002)-&gt;latest()-&gt;get();
  </code></pre>
  <p>The program will works perfectly, how can I pass the <code>user_id</code> value from datatable to controller?</p>