jeudi 17 décembre 2015

i just make a register forum but validation doesnot work. I get following errors:BadMethodCallException in Builder.php line 2071:

whenever i try to register form i get same error.Its been an hour but couldnot figure out.
My validation doesnot working.Is there some mistake in code as i am new in laravel i couldnot figure out. eventhough i fully posted the register form it still shows same error.What actually BadMethodCallException and that builder.php line 2071 that is out of my knowledge.I have following error: Call to undefined method Illuminate\Database\Query\Builder::validate() Here is my User@Controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use View;
use App\Basemodel;
use App\user;
use Input;


class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
     public $restful = true;

    public function index()
    {
        return View::make('users.new')->with('title', 'Make it snappy Q&A - Register');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $validation = User::validate(Input::all());

        if($validation->passes()){
            User::create(array(
                'username'=>Input::get('username'),
                'password'=>Hash::make(Input::get('password'))
                ));
             return Redirect::to_route('home')->with('message','Thanks for registering!');
        } else{
            return Redirect::to_route('register')->with_errors($validation)->with_input();
        }

    }


and my Basemodel is:
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use user;

class Basemodel extends Model
{
   public static function validate($data){
    return Validator::make($data,static::$rules);
   }
}
and my user model is:
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Basemodel;

class user extends Model
{
    public static $rules = array( 
    'username'=>'required|unique:users|alpha_dash|min:4',
    'password'=>'required|alpha_num|between:4,8|confirmed',
    'password_confirmation'=>'required|alpha_num|between:4,8'
    ); 
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire