/**
  * Store a newly created biller in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Biller::$rules);
     $user = Auth::user();
     if ($validator->passes()) {
         // store the biller data
         $this->biller->name = Input::get('name');
         $this->biller->address_1 = Input::get('address_1');
         $this->biller->address_2 = Input::get('address_2');
         $this->biller->city = Input::get('city');
         $this->biller->zip = Input::get('zip');
         $this->biller->state = Input::get('state');
         $this->biller->country_id = Input::get('country_id');
         $this->biller->phone = Input::get('phone');
         $this->biller->mobile = Input::get('mobile');
         $this->biller->fax = Input::get('fax');
         $this->biller->email = Input::get('email');
         $this->biller->web = Input::get('web');
         $this->biller->user_id = $user->id;
         if (Input::hasFile('logo')) {
             $file = Input::file('logo');
             $thumbnail = Image::make($file->getRealPath())->crop(200, 80);
             $destinationPath = 'uploads/' . $user->username . "/billers/";
             $filename_string = sha1(time() . time() . $file->getClientOriginalName());
             $filename = $filename_string . "." . $file->getClientOriginalExtension();
             $filename_thumb = $filename_string . "_thumb" . "." . $file->getClientOriginalExtension();
             if (!File::exists($destinationPath)) {
                 mkdir($destinationPath, 0777, true);
             }
             $upload_success = Input::file('logo')->move($destinationPath, $filename) && $thumbnail->save($destinationPath . "/" . $filename_thumb);
             if ($upload_success) {
                 $this->biller->image_name = $file->getClientOriginalName();
                 $this->biller->image_path = $destinationPath . $filename;
                 $this->biller->image_path_thumbnail = $destinationPath . $filename_thumb;
             }
         }
         if ($this->biller->save()) {
             $this->biller->user_id = $user->id;
             if (Request::ajax()) {
                 return Response::json(array('status' => 'success'));
             }
             return Redirect::to('billers/' . $this->biller->id . '/edit')->with('success', Lang::get('billers.message.success.create'));
         }
     }
     if (Request::ajax()) {
         return Response::json(array('status' => 'error', 'errors' => $validator->errors()->toArray()));
     }
     return Redirect::back()->withErrors($validator)->withInput();
 }