public function store(Request $request)
{
// dd('stop');
$this->validate($request, [
'title' => 'required',
'slug' => 'required|unique:products',
'text' => 'required',
'path' => 'nullable|image',
]);
$product = new Product();
$product->title = $request->input('title');
$product->slug = $request->input('slug');
$product->text = $request->input('text');
$product->keywords = $request->input('keywords');
$product->description = $request->input('description');
$product->published = $request->input('published');
$product->category_id = $request->input('category_id');
// $product->product_id = $request->input('product_id');
$product->price = $request->input('price');
$product->authorized_price = $request->input('authorized_price');
$product->short_description = $request->input('short_description');
$product->save();
// dd('stop');
$image = new Image();
// dd('stop');
$path =public_path().'uploads/product_images';
// dd('stop');
$file = $request->file('file');
dd($file);
// dd($path);
foreach ($file as $f) {
// dd($path);
$filename = str_random(20) .'.' . $f->getClientOriginalExtension() ?: 'png';
// dd($path);
$img = ImageInt::make($f);
// dd($path);
$img->resize(500,500)->save($path . $filename);
// dd($path);
Image::create(['title' => $request->title, 'path' => $filename]);
// dd($path);
}
// dd($path);
$image->path = $request->input('path');
// dd($path);
$image->save();
return redirect('/product/create')->with('info', 'Данные сохранены');
}