/** * like-Action to call with class_name and object_id * * @return null */ public function likeORdis($class_name, $object_id) { if (Auth::user()) { $class_name = "\\" . self::getAppNamespace() . ucfirst($class_name); $object = $class_name::find($object_id); if ($object->liked(Auth::user())) { if ($object->dislike(\Auth::user())) { $type = "disliked"; } else { $type = "error"; } return \Response::json([$type, $object->getLikeCount()]); } else { if ($object->like(\Auth::user())) { $type = "liked"; } else { $type = "error"; } return \Response::json([$type, $object->getLikeCount(), trans("messages.liked")]); } } else { Toastr::warning("please login or register to LIKE or DISLIKE!", $title = "login required", $options = []); return \Response::json("error"); } }
public function personalQuizzes(Request $request, Quiz $quizData) { if (Auth::user()) { try { $quizzes = $this->repository->allOrSearchUsers($request->get('q')); $countUserQuizzes = count($quizzes->where('user_id', Auth::id())); if (count($quizzes) === 0) { Toastr::warning(trans('messages.noQuizzesFound'), $title = trans('messages.noQuizzesFoundTitle'), $options = []); return redirect()->back(); } else { return view('quiz.index', compact('quizzes', 'countUserQuizzes')); } } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } } }
/** * Display the settings for the specified resource. * * @return \Illuminate\Http\Response */ public function showSettings($username, $tab = 'info') { $user = User::where(compact('username'))->firstOrFail(); // Check authorisation and throw 404 if not if (!Auth::user()->allowedTo('edit', 'user', $user)) { return view('errors/404'); } $tabs = ['settings', $tab]; $pt = getPermissionTypes(); $rt = getRoleTypes(); if ($tab == 'password' && Auth::user()->password_reset) { Toastr::warning("Your password was reset by an admin and you are required to choose an new one"); } return view('user/show', compact('user', 'tabs', 'rt', 'pt')); }
public function userPosts(Request $request, Post $postData) { try { $posts = $this->repository->allOrSearchUsers($request->get('q')); $countUserPosts = $this->repository->countUserPosts(); if ($countUserPosts === 0) { Toastr::warning(trans('messages.noPostsFound'), $title = trans('messages.noPostsFoundTitle'), $options = []); return redirect()->back(); } else { return view('pages.blog', compact('posts', 'countUserPosts')); } } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } }