public function update(Request $request, $id) { $geoPoint = GeoPoint::find($id); DB::transaction(function () use($request, $geoPoint) { if ($request->has('location')) { $pregeo = $request->input('location'); if (isset($pregeo['address_components'])) { $geo = $this->processGeoValue($pregeo); $location = Location::firstOrCreate($geo); $location->save(); $geoPoint->location_id = $location->id; } } $geoPoint->description = $request->input('description'); $geoPoint->organization_id = $request->input('organization_id'); $geoPoint->save(); }); return $geoPoint; }
public function update(Request $request, $id) { $activity = Activity::find($id); DB::transaction(function () use($request, $activity) { if ($request->has('location')) { $pregeo = $request->input('location'); if (isset($pregeo['address_components'])) { $geo = $this->processGeoValue($pregeo); $location = Location::firstOrCreate($geo); $location->save(); $activity->location_id = $location->id; } } $activity->title = $request->input('title'); $activity->description = $request->input('description'); $activity->details = $request->input('details'); $activity->main_picture = $request->input('main_picture'); $arr = explode(".", $request->input('event_date'), 2); $event_date = str_replace("T", " ", $arr[0]); $activity->event_date = Carbon::createFromFormat('Y-m-d H:i:s', $event_date); $activity->twitter_hashtag = $request->input('twitter_hashtah'); $activity->instagram_hashtag = $request->input('instagram_hashtag'); $activity->organization_id = $request->input('organization_id'); $activity->center_id = $request->input('center_id'); $activity->coordinators = $request->input('coordinators'); $activity->place = $request->input('place'); $categories = $request->input('categories'); $activity->categories = strtolower(implode(';', collect($categories)->flatten()->toArray())); $activity->center_activity = $request->input('center_activity'); $activity->save(); if ($activity->media_id) { $activityMedia = ActivityMedia::firstOrCreate(['media_id' => $activity->media_id, 'activity_id' => $activity->id]); } }); return $activity; }
public function update(Request $request, $id) { $center = Center::find($id); DB::transaction(function () use($request, $center, $user) { if ($request->has('location') && isset($request->input('location')['address_components'])) { $geo = $this->processGeoValue($request->input('location')); $location = Location::firstOrCreate($geo); $location->save(); $center->location_id = $location->id; } $center->title = $request->input('title'); $center->description = $request->input('description'); $center->details = $request->input('details'); $center->main_picture = $request->input('main_picture'); $center->twitter_hashtag = $request->input('twitter_hashtag'); $center->instagram_hashtag = $request->input('instagram_hashtag'); $center->save(); }); return $center; }