exception - Why NotFoundHttpException in RouteCollection.php line 161 in laravel 5.3 -


i want submit form information table, error showing, if route::resource('userinfo','infocontroller@index'); error gone, can't insert data, solution.

my controller

<?php namespace app\http\controllers;  use illuminate\http\request; use app\http\requests; use app\infomodel;  class infocontroller extends controller {  public function index()  {    $alldata = infomodel::all();    return $alldata;  }   public function create()  {     return view('userinfo.create');  }   public function store(request $request)  {     $input = $request->all();     infomodel:: create($input);     return redirect('infomodel');  } } 

my model

<?php namespace app;  use illuminate\database\eloquent\model;  class infomodel extends model {     protected $table = "info";     protected $fillable = ['name', 'email', 'age', 'hometown']; } 

my route web.php

<?php route::resource('userinfo','infocontroller');  route::get('/solid', function () {     return view('solid.index'); }); 

this view create.blade.php

<!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">      <title>userinfo</title> </head> <body>  <div class="container" style="width:350px; margin:0 auto; margin-top:25px;">  {!! form::open(['route' => 'userinfo.store']) !!}   <div class="form-group">     <label for="name">enter name</label>     <input type="text" class="form-control" name="name" placeholder="enter name">    </div>    <div class="form-group">     <label for="email">email address</label>     <input type="email" class="form-control" name= "email" placeholder="enter email">    </div>     <div class="form-group">     <label for="age">age</label>     <input type="number" class="form-control" name="age" placeholder="enter age">    </div>  <div class="form-group">     <label for="exampleinputemail1">hometown</label>     <input type="text" class="form-control" name="hometown" placeholder="enter hometown">    </div>    <button type="submit" class="btn btn-primary">submit</button>    </div>  {!! form::close() !!}  </div>   </body> </html> 

the problem in store method

public function store(request $request) {     $input = $request->all();     infomodel:: create($input);     return redirect('infomodel'); } 

you redirect user non-existing route infomodel.

try this

public function store(request $request) {     $input = $request->all();     infomodel:: create($input);      // can try 'return back()'     return redirect()->route('userinfo.index'); } 

Comments