/**
  * Handling save profile form
  *
  * @return Response
  */
 public function saveprofile()
 {
     $input = Input::all();
     $id = Auth::user()->id;
     $geo = Geocoder::getCoordinatesForQuery($input['city'] . ', ' . $input['country'] . ', ' . $input['zip']);
     $profile = User::find($id);
     $profile->artist_name = $input['artist_name'];
     $profile->name = $input['name'];
     $profile->country = $input['country'];
     $profile->city = $input['city'];
     $profile->zip = $input['zip'];
     $profile->bio = $input['bio'];
     $profile->phone = $input['phone'];
     $profile->hub = $input['hub'];
     $profile->promo = $input['promo'];
     $profile->profile_url = Str::slug($input['artist_name']);
     $profile->picture = $input['picture_id'];
     $profile->paypal = $input['paypal'];
     if (Input::has('active')) {
         $profile->active = $input['active'];
     }
     $profile->links = $input['links'];
     if ($geo != 'NOT_FOUND') {
         $profile->lat = $geo['lat'];
         $profile->lng = $geo['lng'];
     }
     if (Input::has('web')) {
         foreach ($input['web'] as $w) {
             $link = new WebLink();
             $link->url = $w;
             $link->user = $id;
             $parse = parse_url($w);
             $link->title = $parse['host'];
             $link->save();
         }
     }
     //Disabling validation rules
     $profile::$rules['email'] = '';
     $profile::$rules['agree'] = '';
     $profile->autoHashPasswordAttributes = false;
     if ($profile->save(['artist_name' => 'required|unique:users,artist_name,' . $profile->id, 'profile_url' => 'unique:users,profile_url,' . $profile->id, 'paypal' => 'required|email'])) {
         return Redirect::to('/artist/' . $profile->profile_url);
     } else {
         Input::flash();
         return Redirect::to('profile/settings')->withInput()->with('errors', $profile->errors()->all());
     }
 }
 /**
  * Handle hub form (add/edit)
  *
  * @return Response
  */
 public function post_hub()
 {
     $hub = null;
     if (Input::has('id')) {
         $hub = Hub::find(Input::get('id'));
     }
     if (is_null($hub)) {
         $hub = new Hub();
     }
     $geo = Geocoder::getCoordinatesForQuery(Input::get('location'));
     $hub->name = Input::get('name');
     $hub->description = Input::get('description');
     $hub->location = Input::get('location');
     $hub->facebook = Input::get('facebook');
     $hub->google = Input::get('google');
     $hub->twitter = Input::get('twitter');
     $hub->slug = Str::slug($hub->name);
     if ($geo != 'NOT_FOUND') {
         $hub->lat = $geo['lat'];
         $hub->lng = $geo['lng'];
     }
     if (Input::has('art')) {
         $image = Input::get('art');
         $exp = explode(",", $image);
         $name = str_random(15);
         $data = base64_decode($exp[1]);
         $tempfile = storage_path() . "/temp/" . $name . "";
         file_put_contents($tempfile, $data);
         Image::make($tempfile)->resize(210, 210)->save(storage_path() . "/pictures/" . $name . ".png");
         unlink($tempfile);
         $p = new Picture();
         $p->name = $name;
         $p->user = 0;
         $p->extension = '.png';
         $p->save();
         $hub->picture = $p->id;
     }
     $hub->save();
     return Redirect::to('admin/hubs');
 }