如果是Model的话,不需要这样做。
你是store可以这样写:
public function store()
{
$input = \Input::all();
$validator = \Validator::make($input, Line::getRules('create'), Line::getMessage());
if ($validator->fails())
{
return \Redirect::back()->with('errorCode',1)->withErrors($validator)->withInput();
}else{
if($model = Line::create($input)){
return \Redirect::back()->with('errorCode',0);
}else{
return \Redirect::back()->with('errorCode',2);
}
}
}
Lind的getRules和getMessage和具体的对象没有关系的话,就写成静态方法。
下面的create直接用静态方法。