public function update($id, SliderRequest $request)
 {
     $slider_object = SliderObject::findOrFail($id);
     $request_data = $request->all();
     $request_data['tagline_color'] = $request_data['tagline_color'] . ' ' . $request_data['tagline_shade'] . '-' . $request_data['tagline_shade_value'];
     $request_data['slogan_color'] = $request_data['slogan_color'] . ' ' . $request_data['slogan_shade'] . '-' . $request_data['slogan_shade_value'];
     unset($request_data['tagline_shade']);
     unset($request_data['tagline_shade_value']);
     unset($request_data['slogan_shade']);
     unset($request_data['slogan_shade_value']);
     if ($request->hasFile('image_file')) {
         $path = storage_path('app/slider/');
         $image_file = $request_data['image_file'];
         unset($request_data['image_file']);
         $request_data['image_name'] = $this->generateImageName($image_file->getClientOriginalExtension());
         $request_data['mime_type'] = $image_file->getClientMimeType();
         $this->saveImage($path, $image_file, $request_data['image_name']);
     }
     $slider_object->update($request_data);
     return redirect('articles');
 }
 public function slider_image_store(SliderRequest $request)
 {
     $all_slider = Slider::all();
     if ($all_slider->isEmpty()) {
         $position = 1;
     } else {
         $position = Slider::all()->max('position') + 1;
     }
     $slug = uniqid();
     $file = $request->file('slider_image');
     $file->move('uploads/', $slug . '__' . $file->getClientOriginalName());
     $file_text = $slug . '__' . $file->getClientOriginalName();
     $data = ['heading_text' => $request->get('heading_text'), 'paragraph_text' => $request->get('paragraph_text'), 'button_text' => $request->get('button_text'), 'button_url' => $request->get('button_url'), 'slider_image' => $file_text, 'position' => $position];
     $slider = new Slider($data);
     $slider->save();
     return redirect('/slider/all');
 }
 public function itemStore(SliderRequest $request)
 {
     try {
         $this->slide->create($request->all());
     } catch (VAlidationException $e) {
         return redirect()->back()->withErrors($e->getError());
     }
     $slider_id = $request->input('slider_id');
     return redirect()->route('slider.show', $slider_id)->with('Mess', 'Thêm mới thành công!');
 }