嗨,当我尝试在邮递员中更新图像时出现错误
我的控制器
$validator = Validator::make($request->all(), [
'category_id'=> 'required',
'product_name'=> 'required',
'product_description'=> 'required',
'product_img'=> 'required'
] );
if ($validator -> fails()) {
return $this->sendError('error validation', $validator->errors());
}
$product = Product::findOrFail($id) ;
$product->category_id = $request->input('category_id');
$product->subcat_id = $request->input('subcat_id');
$product->product_name = $request->input('product_name');
$product->product_description = $request->input('product_description');
$product->product_properties = $request->input('product_properties');
$product->product_img = $request->file('product_img')->store('images');
$product->product_pdf = $request->file('product_pdf')->store('files');
if($product->update()){
return $this->sendResponse($product->toArray() , 'Product Updated Succesfully');
}
Run Code Online (Sandbox Code Playgroud)
我的邮递员行
"product_img":"Downloads/screencapture-file-C-Users-gkpro-Desktop-ui-Semantic-UI-master-examples-navbar-html-2019-01-03-20_31_47.png"
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
在 null 上调用成员函数 store()
大家,我需要将图像名称保存在数据库的头像列中,并将图像保存在 public/Storage/users 我的代码这里 将图像链接保存在数据库中,请帮忙。
public function handleProviderCallback($service)
{
$user = Socialite::driver($service)->user();
$FindUser = User::where('email',$user->getEmail())->first();
if($FindUser){
Auth::login($FindUser);
}
else{
$NewUser = new User;
$NewUser->email = $user->getEmail();
$NewUser->name = $user->getName();
$NewUser->avatar = $user->getAvatar();
$NewUser->password = bcrypt(123456);
$NewUser->save();
Auth::login($NewUser);
}
return redirect('/');
}
Run Code Online (Sandbox Code Playgroud)