为什么会出现此错误?
传递给App \ Http \ Controllers \ Controller :: validate()的参数1必须是Illuminate \ Http \ Request的实例,Illuminate \ Support \ Facades \ Request的实例,在C:\ xampp \ htdocs \中调用第55行的spupresearchjournal \ app \ Http \ Controllers \ CurrentIssueController.php
公共功能存储(请求$ request) {
$this->validate($request, [
'journalcover' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'title' => 'required',
'editor' => 'required',
'date' => 'required',
'summary' => 'required',
]);
// check if file was uploaded
if ($request->hasFile('journalcover')) {
// get the file object
$image = $request->file('journalcover');
$name = $image->getClientOriginalName();
//$name['journalcover'] = 'images/' . $request->file('journalcover')->getClientOriginalName();
//$size = $image->getClientSize();
$destinationPath = ('images/');
$image->move($destinationPath, $name);
$journalcover = $destinationPath . $name;
$newjournal = new CurrentIssue;
$newjournal->journalcover = ('images/').$name;
$newjournal->title = $request->input('title');
$newjournal->editor = $request->input('editor');
$newjournal->date = $request->input('date');
$newjournal->summary = $request->input('summary');
$newjournal->status = $request->input('status', '0');
//$newjournal->size = $size;
//dd($newjournal);
$newjournal->save();
return redirect('/currentissue')->with('success', 'New Journal Added');
}
}
传递给App \ Http \ Controllers \ Controller :: validate()的参数1必须是Illuminate \ Http \ Request的实例,Illuminate \ Support \ Facades \ Request的实例,在C:\ xampp \ htdocs \中调用第55行的spupresearchjournal \ app \ Http \ Controllers \ CurrentIssueController.php
答案 0 :(得分:1)
您没有从控制器中的正确名称空间导入类。您希望将Illuminate\Http\Request
类导入文件的顶部,而不是Request Facade类:
use Illuminate\Http\Request;
阅读http://php.net/manual/en/language.namespaces.importing.php有关使用名称空间的信息。