/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = ['title' => 'required', 'sub_title' => 'required', 'image' => 'required|mimes:jpeg,png|max:1000', 'type' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         \Session::flash('message', 'We encountered the following errors:');
         \Session::flash('alert-class', 'alert-danger');
         return \Redirect::to('admin/sliders/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $slider = new Slider();
         $slider->title = Input::get('title');
         $slider->sub_title = Input::get('sub_title');
         $slider->type = Input::get('type');
         $slider->comment1 = Input::get('comment1');
         $slider->comment2 = Input::get('comment2');
         $slider->comment3 = Input::get('comment3');
         $slider->comment4 = Input::get('comment4');
         // image save to uploades folder
         if (Input::file('image')->isValid()) {
             $root = 'public/';
             $destinationPath = 'uploades/slider/';
             // upload path
             $extension = Input::file('image')->getClientOriginalExtension();
             // getting image extension
             $filename = rand(11111, 99999) . '.' . $extension;
             // renameing image
             Input::file('image')->move($root . $destinationPath, $filename);
             // uploading file to given path
             // sending back with message
             // Session::flash('success', 'Upload successfully');
             $slider->image = $destinationPath . $filename;
         }
         // end. image save to uploades folder
         $slider->save();
         // redirect
         \Session::flash('message', 'Successfully created slider!');
         return \Redirect::to('admin/sliders');
     }
 }