title: How to pass a looped dropdown value from view to controller using route in Laravel?
body: <p>I have this dropdown with looped item in it. All I want is when I change the value of the selected item on dropdown it will send the value to the controller using route.</p>
  
  <p>This is the code of looped item in my dropdown in my view named <code>resolution_time_of_calls.blade.php</code>:</p>
  
  <pre><code>&lt;div class="dropdown"&gt;    
          &lt;form action="" method="POST"&gt;
                &lt;select name="year"&gt;
                      &lt;option class="dropdown-item" selected name="years" disabled&gt;--Select Year-- &lt;/option&gt;  
                   &lt;?php 
                      $start = "2017";
                      $end = (int)date("Y");                
                         for($i=$start; $i&lt;=$end; $i++){                  
                               echo '&lt;option class="dropdown-item" value='.$i.'&gt;'.$i.'&lt;/option&gt;';
                            }
                         ?&gt;                          
                &lt;/select&gt; 
          &lt;/form&gt; 
     &lt;/div&gt;
  </code></pre>
  
  <p>This is a screenshot of my dropdown:<a href="https://i.stack.imgur.com/OLJIi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OLJIi.png" alt="enter image description here"></a></p>
  
  <p>All I want is when I changed the Year on my <code>dropdown</code>, the year below the graph will change its year.</p>
  
  <p>I don't have a route for that yet because I don't know what code to write.</p>
  
  <p>This is my controller where the dropdown value should be passed. The value that will be sent by the route should be passed into this function and I don't know how because I'am a newbie in Laravel. Thanks in advance for the help!</p>
  
  <pre><code>public function resolution_time_of_calls(){         
  
          //declarations            
          $arr_val = array();
          $arr_val1 = array();
          $arr_val2 = array();
          $arr_monthname = array();
          $arr_monthInt = array();                   
  
          //SELECTING MONTHS  
          $quer = DB::select("SELECT MONTH(DATE_ADD(T.Created, INTERVAL 8 HOUR)) AS MonthInt
              ,monthname(DATE_ADD(T.Created, INTERVAL 8 HOUR)) AS Month
              ,year(DATE_ADD(T.Created, INTERVAL 8 HOUR)) AS Year               
              FROM rtdb.Tickets T
              LEFT JOIN rtdb.ObjectCustomFieldValues O ON O.ObjectId=T.EffectiveId 
              AND O.CustomField=15 AND O.ObjectType='RT::Ticket' AND O.Disabled=0
              WHERE T.Status!='Deleted' AND T.IsMerged IS NULL AND T.Type='ticket'
              AND year(DATE_ADD(T.Created, INTERVAL 8 HOUR))=2018 
              GROUP BY Month,MonthInt,Year Order by MonthInt asc
              ");   
          $chart = new SampleChart;                            
          $chart-&gt;title('Resolution Time of Calls');                 
          foreach($quer as $query){
              array_push($arr_monthname, $query-&gt;Month.", ".$query-&gt;Year);  
              array_push($arr_monthInt, $query-&gt;MonthInt);   
          }                     
          $chart-&gt;labels($arr_monthname); 
  
          ///////////////////// TOTAL, AVERAGE,MAXIMUM Query  ////////////////////
          foreach($arr_monthInt as $month){
              $sql = DB::select("SELECT MONTH(DATE_ADD(T.Created, INTERVAL 8 HOUR)) AS MonthInt
  
                  ,AVG(TIMESTAMPDIFF(HOUR,T.Created,O.Created)) AS AVG   
                  ,MAX(TIMESTAMPDIFF(HOUR,T.Created,O.Created)) AS MAX               
                  FROM rtdb.Tickets T
                  LEFT JOIN rtdb.ObjectCustomFieldValues O ON O.ObjectId=T.EffectiveId 
                  AND O.CustomField=15 AND O.ObjectType='RT::Ticket' AND O.Disabled=0
                  WHERE T.Status!='Deleted' AND T.IsMerged IS NULL AND T.Type='ticket'
                  AND year(DATE_ADD(T.Created, INTERVAL 8 HOUR))=2018 
                  GROUP BY MonthInt Order by MonthInt asc");
          }
          foreach($sql as $value){
  
              array_push($arr_val1, $value-&gt;AVG );
              array_push($arr_val2, $value-&gt;MAX );
          }
  
          $chart-&gt;dataset('Average Hours', 'bar', $arr_val1)-&gt;backgroundcolor('green');   
          $chart-&gt;dataset('Maximum Hours', 'bar', $arr_val2)-&gt;backgroundcolor('blue');   
          $chart-&gt;height(600);
  
  
      return view('resolution_time_of_calls',['chart'=&gt;$chart]);
  }  
  </code></pre>