public function get($object_id) { $object = Object::findOrFail($object_id); if ($object->isVisibleToUser() && $object->isInMissionControl()) { if (Auth::isSubscriber()) { JavaScript::put(['totalFavorites' => $object->favorites()->count(), 'isFavorited' => Auth::user()->favorites()->where('object_id', $object_id)->first(), 'userNote' => Auth::user()->notes()->where('object_id', $object_id)->first(), 'object' => $object]); } // Item has been viewed, increment! $object->incrementViewCounter(); // Determine what type of object it is to show the correct view $viewType = strtolower(MissionControlType::getKey($object->type)); return view('missionControl.objects.' . $viewType, ['object' => $object, 'moreLikeThis' => Search::moreLikeThis($object->search())]); } // Item cannot be viewed or does not exist return App::abort(401); }