how would it generate a toastr message on validation? You have no code to do this.
Are you using some package that says it will toast errors?
This is working and uploading the image. It is sending the toastr message if successful. Where I am running into trouble is when I try to upload an image not listed in mimes: such as webp . I am trying to see if the error message works. It goes back to the upload page but no toastr message. What am I missing?
public function update(Request $request, $id)
{
$update = User::find($id);
$this->validate($request, [
'name' => 'max:255',
'phone' => 'required|string|max:255',
'email' => 'required|email',
'image' => 'image|mimes:jpg,jpeg,png,gif,svg|max:2048',
]);
if($request->hasFile('image'))
{
$destination = 'backend/images/profile/'.$update->image;
if(File::exists($destination)){
File::delete($destination);
}
$image = $request->file('image');
$filename = time() .'.'.$image->getClientOriginalExtension();
Image::make($image)->save(public_path('backend/images/profile/'.$filename));
$update->image = $filename;
}
$update-> update([
'name' => $request->name,
'phone' => $request->phone,
'email' => $request->email,
]);
if ($update instanceof User) {
// toastr()->success('Profile has been saved successfully!');
toastr()->success('Profile Data Updated Successfully');
return redirect()->route('admin.profile.view');
} else{
toastr()->warning('An error has occurred please try again later.');
return back();
}
}
Please or to participate in this conversation.