2
我想驗證我的形式輸入,但它拋出我這個錯誤在我Laravel.log文件'方法[validateString]不存在。'在laravel驗證
production.ERROR:「方法[validateString]不存在」例外「BadMethodCallException」有消息在C:\ XAMPP \ htdocs中\測試\供應商\ laravel \框架的\ src \照亮\確認\ Validator.php:2405
這是我的狗模型
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);
}
}
而且在我的狗控制器在這裏我驗證我的數據
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);
}
任何想法我做錯了什麼?
非常感謝您的幫助。
有你的鏈接... – Tom
@Tom thx,更新到包括比4.1更新的版本。 – lagbox