public function update(Slider $slider_item, Request $request) { $rules = array('w' => 'notcontains0'); $messages = ['w.notcontains0' => "Er was geen image crop selectie"]; $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return redirect('cms/home/slider/' . $slider_item->id)->withErrors($validator)->withInput(); } else { $this->dispatch(new HomeSliderImageProcess($slider_item)); $slider_item->title = Input::get('slider_title'); $slider_item->active_flag = Input::get('slider_active') == 'on' ? 1 : 0; $slider_item->link = $request->get("slider_link") ? $request->get("slider_link") : ""; $slider_item->save(); return redirect('cms/home/slider'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $formData = Input::all(); $slider = new Slider(); $upload_success = null; if (isset($formData['image'])) { $file = $formData['image']; $destinationPath = public_path() . $this->imgDir; $fileName = $file->getClientOriginalName(); $fileSize = $file->getClientSize(); $upload_success = $file->move($destinationPath, $fileName); // resizing an uploaded file Image::make($destinationPath . $fileName)->resize($this->width, $this->height)->save($destinationPath . $fileName); $slider->file_name = $fileName; $slider->file_size = $fileSize; $slider->path = $this->imgDir . $fileName; } $slider->title = $formData['title']; $slider->description = $formData['description']; $slider->save(); Flash::message('Slider was successfully added'); return langRedirectRoute('admin.slider.index'); }
public function postCreate() { $image = Input::file('image'); $slide = new Slider(); $slide->link = Input::get('link'); $slide->weight = Input::get('weight'); if ($image) { $slide->title = $image->getClientOriginalName(); $filename = date('Y-m-d-H:i:s') . "-" . $slide->title; $path = public_path('img/slider/' . $filename); $path_thumb = public_path('img/slider/thumb/' . $filename); list($widht, $height) = getimagesize($image); $coef_proportion = $widht / $height; $height_original = 320; $height_thumb = 120; $width_original = $coef_proportion * $height_original; $width_thumb = $coef_proportion * $height_thumb; Image::make($image->getRealPath())->resize($width_original, $height_original)->save($path); Image::make($image->getRealPath())->resize($width_thumb, $height_thumb)->save($path_thumb); $slide->image = $filename; } $slide->save(); return Redirect::back(); }