/** * 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'); }