/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $service_id)
 {
     // get the service
     $service = Service::find($service_id);
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = ['title' => 'required', 'sub_title' => 'required', 'text' => 'required', 'image' => 'required|mimes:jpeg,png|max:10000'];
     $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/service_details/' . $service->id . '/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $service_detail = new Service_detail();
         $service_detail->service_id = $service->id;
         $service_detail->title = Input::get('title');
         $service_detail->sub_title = Input::get('sub_title');
         $service_detail->position = Input::get('position');
         $service_detail->text = Input::get('text');
         // image save to uploades folder
         if (Input::file('image')->isValid()) {
             $root = 'public/';
             $destinationPath = 'uploades/service_detail/';
             // 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');
             $service_detail->image = $destinationPath . $filename;
         }
         // end. image save to uploades folder
         $service_detail->save();
         // redirect
         \Session::flash('message', 'Successfully created service_detail!');
         return \Redirect::to('admin/service_details/' . $service->id);
     }
 }