When I upload an image, it perfectly keeps the image's path in the database, whose field is "image", but it does not save the image as such in the public folder as specified in the code.
In the create view of my project I use Form, so I read that I had to modify it in the following way to upload files:
{!! Form::open(['route' => 'products.store', 'files' => True]) !!}
In the controller I have the following for the "store" and "update" methods:
//IMAGE
if($request->file('image')){
$path = Storage::disk('public')->put('image', $request->file('image'));
$product->fill(['image' => asset($path)])->save();
}
Neither is the type of image validating me, but the other fields do. I leave the validation code:
public function rules()
{
return [
'name' => 'required',
'short' => 'required',
'body' => 'required'
];
if($this->get('image'))
$rules = array_merge($rules, ['image' => 'mimes:jpg,jpeg,png']);
return $rules;
}
Now configure the config fylesystems by placing the root path as follows:
'root' => public_path(),