Q:

Laravel Route for Search

I try this tutorial on laravel about Live Search  
But it's on the homepage(index)
I want to access it to localhost/laravel/public/search
Here is the Controller
class SearchController extends Controller
{
public function index()
{
return view('search.search');
}

public function search(Request $request)
{
   if ($request->ajax())
       $output ="";
       $orderinfo=DB::table('tb_order')->where('shipcustomername','LIKE','%' . $request->search.'%' )
                                       ->orWhere('orderId','LIKE','%' .$request->search. '%')->get();

   if ($orderinfo)
   {

       foreach ($orderinfo as $key =>$orderinfo ){

       $output.='<tr>' . 
               '<td>' .$orderinfo->orderId  .'</td>' .
               '<td>' .$orderinfo->email  .'</td>' .
               '<td>' .$orderinfo->subsource  .'</td>' .

               '</tr>';   

       }

       return Response($output);

   }

and my route 
Route::get('/' ,'SearchController@index');
Route::get('/search' ,'SearchController@search');

on my resources folder
i have folder search and it's contain the search.blade.php
 <div class="container">
        <div class="row">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3>Order Info</h3>               
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <input type="text" class="form-control" id="search" name="search"></input>                 
                </div>
                <table class="table table-bordered table-hover ">
                    <thead>
                        <tr>
                            <th>OrderID</th>
                            <th>Email</th>
                            <th>SubSource</th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                   </table>       
                </div>
        </div>
    </div>
        <script type="text/javascript">
            $('#search').on('keyup',function(){
               $value=$(this).val();
               $.ajax({

                  type : 'get',
                  url  : '{{URL::to('search')}}',
                  data : {'search':$value},
                  success:function(data){
                      $('tbody').html(data);                   
                  }

               });
            });
        </script>

</body>

I know this is the route for index ,
 Route::get('/' ,'SearchController@index');

But if try to change this to 
 Route::get('search' ,'SearchController@index');

I get error 500
What is the correct way to route this so it will not use the index
Thank you  

A:

There is a good chance that you are sending empty data try to change this:
$value=$(this).val();

to this:
var value = $('#search').val();

If no that then also you are not submitting the data as well add the form:
{{ Form::open(array('method'=>'GET','class'=> 'col-md-6','url' => '/search', 'id'=>'searchform')) }}

<div class="form-group">
   <input type="text" class="form-control" id="search" name="search"></input>                 
</div>

  {{ Form::close() }}

change your ajax request to this:
 $('#searchform').on('submit', function(e) {
       e.preventDefault(); 
       var search = $('#search').val();
       $.ajax({
           type: "GET",
           url: {{URL::to('search')}},
           data: {search:search}
           success:function(data){
                      $('tbody').html(data);                   
                  }
       });
   });

If not that then:
set APP_DEBUG in .env to true since the request is ajax, using chrome and press f12, go to Network tab -> click on error -> preview tab, if it just say error with a blank screen, then maybe you should chmod 775(write permissions) and try again

