laravel - Store method not working using resource route -


i having trouble figuring out why data not being posted , stored in database. have used resource routes form , works fine, here reason won't work. clicking submit seems refresh page, no errors work from!

so have form gets workout routines database, , on submission want create new workout "session" in database table (called "workouts"). form this:

{{ form::open(array('url' => '/')) }}              <div class="form-group">                 {{ form::text('workout_name', input::old('workout_name'), array('class' => 'form-control', 'placeholder' => 'session name')) }}             </div>              <div class="form-group">                 {{ form::select('routines', $routine_names, null, array('class' => 'form-control')) }}             </div>                  {{ form::submit('select routine', array('class' => 'btn btn-success pull-right')) }}              {{ form::close() }} 

in homecontroller have this:

<?php  namespace app\http\controllers;  use illuminate\http\request;  use app\http\requests; use app\http\controllers\controller; use app\routine; use app\workout;  class homecontroller extends controller {  public function index() {     $routines = routine::all();     $routine_names = routine::lists('routine_name');      return view('workout')->with(array('routines'=>$routines, 'routine_names'=>$routine_names)); }  public function store() {      $workout = new workout;     $workout->workout_name = input::get('workout_name');     $workout->save();  } 

}

i have model created workout, , route page following:

route::resource('/', 'homecontroller'); 

i can't figure out i'm going wrong. index method in controller working, returning correct view data need. form looks ok think, i'm posting same page, submitting doesn't seem carry out code have in store method of homecontroller.

any appreciated!

thanks :)

change route declaration from:

route::resource('/', 'homecontroller'); 

to this:

route::resource('/workout', 'workoutcontroller'); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -