当我尝试更新文件时,出现如下错误:
使用未定义的常量名称-假定为“名称”(在将来的PHP版本中将引发错误)
public function update(Request $request, $id)
{
$this->validate($request,[
'name'=>'required',
'designation'=>'required',
'contact_ph'=>'required',
'contact_email'=>'required',
'featured'=>'mimes:jpeg,pdf,docx,png:5000',
]);
$staff=Staff::find($id);
if($request->hasFile('featured'))
{
$featured=$request->featured;
$featured_new_name =time() .$featured->getClientOriginalName();
$featured->move('uploads/srcpost', $featured_new_name);
$staff->featured='uploads/srcposts/'. $featured_new_name;
}
$staff->name=$request=name;
$staff->designation=$request=designation;
$staff->ordering=$request=ordering;
$staff->save();
return redirect()->back();
}
答案 0 :(得分:1)
从$request
检索变量的几种方法如下所示:
$request->name;
$request->get('name');
$request->input('name');
因此,您的代码可以正确执行。
替换您的代码:
$staff->name=$request=name;
$staff->designation=$request=designation;
$staff->ordering=$request=ordering;
具有以下内容:
$staff->name=$request->name;
$staff->designation=$request->designation;
$staff->ordering=$request->ordering;
答案 1 :(得分:0)
使用未定义的常量 'content' - 假定为 ''content''(这将在 PHP 的未来版本中引发错误)(查看:C:\wamp64\www\amadotester\resources\views\welcome.blade。 php)