我有这个StoreMessageRequest
public function rules(): array {
return [
'message' => [
'required',
'string',
'max:60',
],
];
}
导致 MessageController
public function store(StoreMessageRequest $request, Message $message) {
......
}
然后我可以运行查询
$message = new Message([
'user_id' => auth()->id(),
'message' => $request->message
]);
$message->save($message);
这安全吗还是我应该使用
$request->safe()->message
~$validated = $request->safe()->all();
或$validated = $request->validated();
?