I want to validate my form input but it throws me this error in my Laravel.log file
production.ERROR: exception 'BadMethodCallException' with message 'Method [validateString] does not exist.' in C:\xampp\htdocs\testing\vendor\laravel\framework\src\Illuminate\Validation\Validator.php:2405
This is my Dog model
class Dog extends Eloquent { // Add your validation rules here public static $rules = [ 'name' => 'required|string', 'age' => 'required|integer' ]; public static $customMessages = array( 'required' => 'Man the Name atribute is REQUIRED. Fill it man.' ); // Don't forget to fill this array protected $fillable = ['name', 'age']; public static function validate($data) { return Validator::make($data, static::$rules); } }
And in my DogsController here I validate my data
public function update($id) { $dog = $this->DogRepo->find($id); if($dog) { // $dog = $this->dogRepo->update(array_merge(['id' => $id], Input::all())); $validation = Dog::validate(Input::all()); if ($validation->fails()) { return 'wrong data'; } else { return 'ok data'; } if($dog->save()) { return Redirect::route('dogs.show', $id)->with('message', 'The dog has been updated!'); } return Redirect::route('dogs.edit', $id)->withInput()->withErrors($this->dogRepo->errors()); } App::abort(404); } Any Ideas what I'm doing wrong?
Thank you very much for any help.