lundi 3 octobre 2016

Some problems with routes in larabel 5

I'm very new with laravel 5 and I'm trying to do a small app with it. I have the next error and I don't know what to do.

MethodNotAllowedHttpException in RouteCollection.php line 218:
 in RouteCollection.php line 218
 at RouteCollection->methodNotAllowed(array('GET', 'HEAD')) in   RouteCollection.php line 205
 at RouteCollection->getRouteForMethods(object(Request), array('GET', 'HEAD')) 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 54

Problems are in routes where I have this:

Route::get('/', function () {
return view('welcome');
});

Route::get('principal', function () {
return view('principal');
});

 Route::resource('trivago','TrivagoController');

My TrivagoController is as simple as:

<?php

   namespace App\Http\Controllers;

   use Illuminate\Http\Request;

   use App\Http\Requests;

class TrivagoController extends Controller
{
//
  public function index()
  {

  }
  public function show()
  {

  }
  public function create()
  {

  }
  public function store()
  {
    return "Aquí estoy";

  }
  public function destroy()
  {

  }
}

And finally my view is:

 @extends('layouts/principal')
 @section('content')
 {!!Form::open(['route'=>'trivago.store'])!!}
   <div class="form-group">
     {!!Form::label('Fecha Inicio:')!!}
     {!!Form::text('date',null,['class'=>'date datepicker'])!!}

   </div>
  <div class="form-group">
     {!!Form::label('Fecha Final:')!!}
     {!!Form::text('dateout',null,['class'=>'date datepicker'])!!}

  </div>
  <div class="form-group">
     {!!Form::label('Nº Huespedes:')!!}
     {!!Form::text('nhuespedes',null,['class'=>'form-control'])!!}

   </div>
   {!!Form::submit('Comprobar',['class'=>'btn btn-primary'])!!}


{!!Form::close()!!}

@stop

So what I'm doing wrong?. Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire