/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param String $model * @return mixed */ public function handle($request, Closure $next, $model) { if ($model == 'Mission') { Mission::whereSlug(Route::input('slug'))->firstOrFail(); } elseif ($model == 'Object') { Object::findOrFail(Route::input('object_id')); } elseif ($model == 'Tag') { Tag::where('name', Route::input('slug'))->firstOrFail(); } return $next($request); }
public function patchEdit(EditObjectRequest $request, $objectId) { $object = Object::findOrFail($objectId); DB::transation(function () use($objectId, $object) { // Create a snapshot of the object at this point in time ObjectRevision::create(array('object_id' => $objectId, 'user_id' => Auth::id(), 'object' => $object->toJson(), 'changelog' => Input::get('metadata.changelog'), 'did_file_change' => false)); // Update the object $object->title = Input::get('object.title'); $object->summary = Input::get('object.summary'); $object->author = Input::get('object.author'); $object->attribution = Input::get('object.attribution'); $object->save(); Redis::sadd('objects:toReindex', $object->object_id); }); return response()->json(null, 204); }