Level 60
So what's the problem? Can't save an array ( paths ) into docs column?
How do I store file paths of multiple file upload input. Below is my controller so far
public function postDeal(Request $request)
{
$this->validate($request, [
'property_address' => 'string|required|max:100',
'sell_price' => 'string|required|max:100',
'docs' => 'required|max:10000',
]);
$files = $request->file('docs');
$paths = [];
foreach( $files as $file) {
$extension = $file->getClientOriginalExtension();
$filename = 'sup-doc-' . time() . '.' . $extension;
$paths[] = $file->storeAs('Deals', $filename);
}
$deal = new Deal([
'property_address' => $request->input('property_address'),
'sell_price' => $request->input('sell_price'),
'docs' => $paths,
]);
$deal->save();
}
Please or to participate in this conversation.