php - Laravel : BadMethodCallException Method [store] does not exist -


i downloaded , started new project latest laravel 4.2. when trying submit form following error : badmethodcallexception method [store] not exist

here files : controller - admin/admincontroller

<?php   namespace admin;    use illuminate\support\facades\view;   use app\services\validators\articlevalidator;   use input, notification, redirect, sentry, str;    class admincontroller extends \basecontroller {        public function index() {            if (input::has('login')) {                $rules = array(                   'email' => 'required',                   'password' => 'required|min:3',                   'email' => 'required|email|unique:users'               );                $validator = validator::make(input::all(), $rules);                if ($validator->fails()) {                   return redirect::to('admin\admincontroller')->witherrors($validator);                } else {                    // redirect                   session::flash('message', 'successfully created user!');                   return redirect::to('admin\admincontroller');               }           }           $data['title'] = admin;           return view::make('admin.index', $data);       }   } 

view page - admin/index.blade.php

<div class="container">         {{ form::open(array('url' => admin,'id' => 'login')) }}              <div id="icdev-login-wrap">               <div class="raw align-center logoadmin">{{ html::image('images/logo.png') }}</div>             <div id="icdev-login">             <h3>welcome, please login</h3>                     <div class="mar2_bttm input-group-lg"><input type="text" class="form-control loginput" placeholder="email" name="email"></div>                  <div class="mar2_bttm input-group-lg"><input type="password" class="form-control loginput" placeholder="password" name="password"></div>                 <div ><input type="submit" class="btn btn-default btn-lg btn-block cus-log-in" value="login" /></div>                 <div class="row align-center forgotfix">                    <input type="hidden" name="login" value="1">                 </div>                 </div>                 <div>                  </div>             </div>             {{ form::close() }}             </div> 

the error message tells problem is: method called store() doesn’t exist. add controller:

<?php namespace admin;  use illuminate\support\facades\view; use app\services\validators\articlevalidator; use input, notification, redirect, sentry, str;  class admincontroller extends \basecontroller {      public function index()     {         // leave code     }      public function store()     {         // new store method         // put logic here save record database     }  } 

a couple of points:

  • use camel-casing name spaces (i.e. namespace admin should namespace admin)
  • read laravel documentation on resource controllers: http://laravel.com/docs/controllers#resource-controllers
  • you can automatically generate resource controllers artisan command. run $ php artisan make:controller itemcontroller, replacing itemcontroller name of controller, i.e. articlecontroller or usercontroller.

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -