1pppp

Untitled

Aug 2nd, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. public function store(Request $request)
  2. {
  3. // dd('stop');
  4.  
  5. $this->validate($request, [
  6. 'title' => 'required',
  7. 'slug' => 'required|unique:categories',
  8. 'text' => 'required',
  9. 'product_image' => 'nullable|image',
  10.  
  11. ]);
  12.  
  13. $product = new Product();
  14. $product->title = $request->input('title');
  15. $product->slug = $request->input('slug');
  16. $product->text = $request->input('text');
  17. $product->keywords = $request->input('keywords');
  18. $product->description = $request->input('description');
  19. $product->published = $request->input('published');
  20. $product->category_id = $request->input('category_id');
  21. // $product->product_id = $request->input('product_id');
  22. $product->price = $request->input('price');
  23. $product->authorized_price = $request->input('authorized_price');
  24. $product->product_image = $request->input('product_image');
  25. $product->short_description = $request->input('short_description');
  26. $product->save();
  27. $path =public_path().'\uploads\product_images';
  28. $file = $request->file('file');
  29. foreach ($file as $f) {
  30. $filename = str_random(20) .'.' . $f->getClientOriginalExtension() ?: 'png';
  31. $img = ImageInt::make($f);
  32. $img->resize(500,500)->save($path . $filename);
  33. Image::create(['title' => $request->title, 'path' => $filename]);
  34. }
  35.  
  36.  
  37.  
  38. return redirect('/product/create')->with('info', 'Данные сохранены');
  39. }
Advertisement
Add Comment
Please, Sign In to add comment