Advertisement
majweb

Untitled

May 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public function store(Request $request)
  2. {
  3. $this->validate($request, [
  4. 'photo' => 'mimes:jpeg,bmp,png|dimensions:min_width=1024,min_height=768|required'
  5. ], $messages = [
  6. 'photo.required' => 'Wymagany obrazek',
  7. 'photo.mimes' => 'Załaduj obrazek w formacie jpeg,bmp,png!',
  8. 'photo.dimensions' => 'Minimalna rozdzielczość 1024 x 768!'
  9. ]);
  10. $galeria = new Dogallery();
  11. if ($request->hasFile('photo'))
  12. {
  13. $image = $request->file('photo');
  14. $imagename = uniqid('cwiczenie_').'.'. $image->getClientOriginalExtension();
  15. $image->storeAs('public/admin/cwiczenia/', $imagename);
  16. $galeria->photo = $imagename;
  17. } else{
  18. $galeria->photo = 'user.png';
  19. }
  20. $galeria->save();
  21. $galeria->exercise()->attach($galeria); // zapisuje mi w pivot autonumerowane id exercise a nie id obecnego exercise
  22.  
  23. return redirect()->route('admin.cwiczenia.index')->with(['success' => 'Dodałeś zdjęcie']);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement