Laravel 5.4 form post and save() don't work -


i have problem submitting data database. database works fine, can seed data , display data it. suspecting there wrong post form, don't errors, post doesn't reach controller @ all. here files:

view:

@extends('layouts.master')  @section('title') homepage @endsection  @section('content')     <h1>homepage:</h1>     <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. ad architecto aut consectetur debitis deleniti dolore ducimus, eaque ex, harum itaque laudantium nobis odit, officiis quae rem saepe sunt unde veritatis!</p>         <div style=" width: 100%; text-align: center; display: inline-block;">          @foreach($actions $action)             <a href="{{route('niceaction',['action'=>lcfirst($action->name)])}}"><h3>{{ $action->name }}</h3></a>             <br>         @endforeach      </div>      <div>     <form action=" {{ route ('add_action') }}" method ="post">         <label for="name">enter name:</label>         <input type="text" name="name" id="name"/>         <label for="niceness">niceness level:</label>         <input type="text" name="niceness" id="niceness"/>         <button type="submit" >do nice action!</button>        <input type="hidden" value="{{csrf_token()}}" name="_token"/>     </form>       </div> @endsection 

route:

<?php  use illuminate\http\request;  /* |-------------------------------------------------------------------------- | web routes |-------------------------------------------------------------------------- | | here can register web routes application. these | routes loaded routeserviceprovider within group | contains "web" middleware group. create great! | */  route::group(['middleware' => ['web']], function() {      route::get('/', [         'uses' => 'niceactioncontroller@gethome',         'as' => 'home'     ]);       route::group(['prefix'=> 'do'], function(){          route::get('/{action}/{name?}', [             'uses' => 'niceactioncontroller@getniceaction',             'as' => 'niceaction'         ]);            route::post('/add_action', [             'uses' => 'niceactioncontroller@postinsertniceaction',             'as' => 'add_action'         ]);      });  }); 

and controller:

<?php  namespace app\http\controllers;   use illuminate\http\request; use app\http\controllers\controller; use app\niceaction;  class niceactioncontroller extends controller {      public function gethome() {         $actions = niceaction::all();         return view ('home', ['actions' => $actions]);     }      public function getniceaction ($action, $name = null) {          if ($name === null ) {             $name = 'you';         }         return view ('actions.nice', [             'action' => $action,             'name'=> $name             ]);     }      public function postinsertniceaction (request $request) {           $this->validate($request, [             'action' => 'required',             'name' => 'required|alpha',             'niceness' => 'required|numeric'         ]);           $action = new niceaction();         $action->name = $request['name'];         $action->niceness = $request['niceness'];         $action->save();          $actions = niceaction::all();         return view ('home', ['actions' => $actions]);      }      private function transformname($name){         $prefix = 'king ';         return $prefix.strtoupper($name);     } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -