在我的控制器中:
public function getData(\App\Http\Requests\NewNameRequest $request)
{
return 'Your name is : '.$request->input('myName');
}
在我的NewNameRequest.php类
中
namespace App\Http\Requests;
use App\Http\Requests\Request;
class NewNameRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'myName'=>'required|min:3|max:10'
];
}
}
我想要的是......
if(NewNameRequest失败) { 做这个... } 其他 { 在控制器中继续前进 }
及时感谢