我用的是拉瑞威7号
我有一个已生成的请求,但所需的规则不起作用。请求发送回来,没有任何错误。
并且dd()也没有示出请求数据。
- 功能:**
public function store(StoreRequest $request)
{
dd($request->all());
if (!auth()->user()->can('add-users')) {
abort(401);
}
try {
$userStatus = app(CreateUser::class)->execute($request->all());
if ($userStatus == true) {
return redirect()->back()->with('success', 'User successfully created.');
} else {
return redirect()->back()->with('error', 'Oops Something went wrong!');
}
} catch (\Exception $ex) {
return redirect()->back()->with('error', $ex->getMessage());
}
}
- 请求代码:**
class StoreRequest extends FormRequest
{
/**
* 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 [
'name' => ['required','string','max:255'],
'email' => ['required','string','max:255'],
'password' => 'required',
'organization_id' => 'required'
];
}
}
如果我使用Illuminate\Http\Request
显示请求数据但不验证数据。
你知道吗?
1条答案
按热度按时间7uhlpewt1#
你能试试这个吗