2016-10-07 3 views
1

Ich arbeite an Laravel 5.3 Suchfunktion, dieLaravel 5.3 Suche MethodNotAllowedHttpException in RouteCollection.php Linie 218:

unten service_provided in der Tabelle genannten Dienstleistungen suchen soll ist meine Form

@extends('layouts.app') 
@section('title', '| View Search Results') 
@section('content') 
<div class="container"> 
<div class="flex-center position-ref full-height"> 


      <div class="content"> 
       <div class="title m-b-md"> 
        Service 
       </div> 
       {!! Form::open(['route' => 'search.create']) !!} 
       <div class="container" id="SearchBox"> 
       <div class="col-xs-8 col-xs-offset-2"> 

       <div class="input-group"> 

       {!! Form::text('search',null,array('class' => 'form-control','placeholder' => 'Search term...','aria-describedby' => 'basic-addon2')) !!} 
        <span class="input-group-addon" id="basic-addon2"> 
        {!! Form::submit('Search',array('class'=> 'btn btn-default')) !!} 
        </span> 
       </div> 

       </div> 
       </div> 
       {!! Form::close() !!} 

      </div> 
     </div> 
</div> 

@endsection 

Mein Seach erstellen Funktion ist als unten

public function create(Request $request) 
    { 
     //// Gets the query string from our form submission 
    $query = $request->input('search'); 
    // Returns an array of articles that have the query string located somewhere within 
    // our articles titles. Paginates them so we can break up lots of search results. 
    $services = DB::table('services')->where('city', 'LIKE', '%' . $query . '%')->paginate(10); 

    // returns a view and passes the view the list of articles and the original query. 
    return view('search.search', compact('services', 'query')); 
    } 

meine Strecke

wie folgt
Route::get('search.index',array('as'=>'index','uses'=>'[email protected]')); 
Route::get('search.create',array('as'=> 'create','[email protected]')); 

Die Fehlermeldung im bekommen, wenn ich das Formular wie unten

Whoops ist, sieht aus wie etwas schief gelaufen ist. 1/1 MethodNotAllowedHttpException in /home/archie/servicepap/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php Leitung 218:

in RouteCollection.php line 218 
at RouteCollection->methodNotAllowed(array('GET', 'HEAD', 'PUT', 'PATCH', 'DELETE')) in RouteCollection.php line 205 
at RouteCollection->getRouteForMethods(object(Request), array('GET', 'HEAD', 'PUT', 'PATCH', 'DELETE')) in RouteCollection.php line 158 
at RouteCollection->match(object(Request)) in Router.php line 780 
at Router->findRoute(object(Request)) in Router.php line 610 
at Router->dispatchToRoute(object(Request)) in Router.php line 596 
at Router->dispatch(object(Request)) in Kernel.php line 267 
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104 
at Pipeline->then(object(Closure)) in Kernel.php line 149 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 
at Kernel->handle(object(Request)) in index.php line 53 
at require_once('/home/archie/servicepap/public/index.php') in server.php line 21 

Antwort

0

Hallo, ich hatte auch diese Herausforderung aber mein Problem war, dass ich versuche, meine Anwendung auf einer diffrent plat Form zu starten, so musste ich als meine Routen ändern unten

Ihr Code :::

Route::get('search.index',array('as'=>'index','uses'=>'[email protected]')); 
Route::get('search.create',array('as'=> 'create','[email protected]')); 

ändern es

Route::any('search.index',array('as'=>'index','uses'=>'[email protected]')); 
Route::any('search.create',array('as'=> 'create','[email protected]')); 

aber dies ist nicht der beste Weg, um ::: .. können Sie Match verwenden und eine Reihe von Ihrer http Verben spezifizieren

1

Formular sendet post Anfrage standardmäßig so diese Route verwendet werden:

Route::post('search/create', array('as'=> 'search.create', '[email protected]')); 
+0

i noch zu tun haben, dass immer der gleiche Fehler –

+0

Versuchen Sie, die Methode explizit zu setzen '{!! Form :: open (['Methode' => 'Post', 'route' => 'search.create']) !!} ' –

+0

@AlexyMezenin Immer noch den gleichen Fehler –

Verwandte Themen