public function __construct() { $this->middleware('auth', ['except' => ['index', 'show']]); $this->middleware('author:article', ['except' => ['index', 'show', 'create']]); view()->share('allTags', Tag::with('articles')->get()); parent::__construct(); }
public function get($id) { $article = Tag::with('articles.tags')->find($id); if (!$article) { return response()->json(null, 404); } return response()->json($article); }
public function __construct() { $this->middleware('auth', ['except' => ['index', 'show']]); $this->middleware('author:article', ['only' => ['update', 'destroy', 'pickBest']]); $allTags = taggable() ? Tag::with('articles')->remember(5)->cacheTags('tags')->get() : Tag::with('articles')->remember(5)->get(); view()->share('allTags', $allTags); parent::__construct(); }
/** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { $works = $this->repository->with('tags')->all(); $tags = Tag::with(['posts' => function (BelongsToMany $query) { $query->where('type', 'work'); }])->get(); return view('frontend.pages.works.index', compact('works', 'tags')); }
public function showTag($name) { $tag = Tag::with('articles')->where('name', $name)->first(); if (!$tag) { abort(404); } else { $articles = $tag->articles()->latest()->paginate(5); return view('front.index', ['page_tag' => $tag->name, 'articles' => $articles, 'tags' => $this->tags, 'setting' => $this->setting, 'links' => $this->links]); } }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { if ($request->input('tags')) { $tag = Tag::with('posts')->whereName($request->input('tags'))->firstOrFail(); $posts = $tag->posts; } else { $posts = Post::with('tags')->published()->latest('published_at')->get(); } return view('blog.index')->with(compact('posts')); }
public function edit($id) { //Get data related article from database $article = Article::find($id); $tags = Tag::with(['user' => function ($query) { $query->where('id', Auth::id()); }])->orderBy('count', 'desc')->orderBy('updated_at', 'desc')->get(); $tagUsed = $article->tags; $type = ['Original', 'Reproduction', 'Translation']; return view('edit', ['article' => $article, 'tags' => $tags, 'tagUsed' => $tagUsed, 'type' => $type[$article->type]]); }
public function __construct() { $this->middleware('author:article', ['only' => ['update', 'destroy', 'pickBest']]); if (!is_api_request()) { $this->middleware('auth', ['except' => ['index', 'show']]); $allTags = \Cache::remember('tags', 30, function () { return Tag::with('articles')->get(); }); view()->share('allTags', $allTags); } parent::__construct(); }
public function __construct() { $this->middleware('auth'); $this->sidebarTags = Tag::with(['user' => function ($query) { $query->where('id', Auth::id()); }])->where('count', '>=', '0')->orderBy('count', 'desc')->orderBy('updated_at', 'desc')->take(8)->get(); $this->recentPosts = Article::where('article_uid', Auth::id())->orderBy('created_at', 'desc')->take(3)->get(); $this->userProfile = UserProfile::where('user_id', Auth::id())->get()->first(); View::share('sidebarTags', $this->sidebarTags); View::share('recentPosts', $this->recentPosts); View::share('userProfile', $this->userProfile); }
public function showEntriesByTag($id) { $tag = Tag::with('entries')->where('id', '=', $id)->first(); return view('tag.entries', compact('tag')); }
public function getTagged($tagSlug) { $tag = Tag::with(['photos' => function ($q) { $q->orderBy('id', 'desc'); }, 'photos.tags'])->whereSlug($tagSlug)->first(); if (!$tag) { return redirect('/')->withError('Tag ' . $tagSlug . ' not found'); } return view('photos.list')->withTitle('Photos Tagged With: ' . $tagSlug)->withPhotos($tag->photos()->paginate(config('whatthetag.pagination_count'))); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return \App\Tag::with(['user', 'bookmarks'])->find($id); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $tags = Tag::with('articles')->orderBy('name')->get(); return view('blog.tags.index', compact('tags')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // return \App\Tag::with(['tagBookmarks', 'users'])->find($id); }
public function index() { $posts = Post::with('tags')->orderBy('id')->get(); $tags = Tag::with('posts')->get(); return view('admin.index', compact('posts', 'tags')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $tag = Tag::with('instrumentos')->findOrFail($id); return view('tags.show', compact('tag')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return App\Tag::with('bookmarks')->find($id); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return Tag::with('bookmarks')->findOrFail($id); }
public function statistics() { $frequentTags = Tag::with('articles')->get()->take(10)->map(function ($t) { return ['label' => $t->name, 'data' => $t->articles()->get()->count()]; }); $activeBloggers = Blog::with('articles')->get()->take(10)->map(function ($b) { return ['username' => $b->username, 'articlesCount' => $b->articles()->get()->count()]; }); $mostVisitedBlogs = Blog::with('user')->get()->take(10)->map(function ($b) { return ['label' => $b->user['firstName'] . ' ' . $b->user['firstName'] . ' (' . $b->username . ')', 'data' => $b->views]; }); $disabledBlogsCount = Blog::with('user')->where('status', 'inactive')->count(); return ['frequentTags' => $frequentTags, 'activeBloggers' => $activeBloggers, 'mostVisitedBlogs' => $mostVisitedBlogs, 'disabledBlogsCount' => $disabledBlogsCount, 'studentsCount' => User::where('role', '=', 'eleve')->get()->count(), 'teachersCount' => User::where('role', '=', 'prof')->get()->count(), 'articlesCount' => Article::all()->count()]; }
/** * Show the forum dashboard. * * @return Response */ public function getForum() { $tagFilters = config('forum.tag_filters'); $userFilters = $this->getUserFilters($tagFilters); $activityOfTagsLimitInDays = config('forum.days_before_unactive_tag', 10); self::checkFilters($tagFilters); switch ($userFilters->tags_filter_by) { /** * Displaying the classic way. * * We show the tags ordering them by categories. */ case 'classic': /** * Selecting the Categories following the filters applied by the user. */ switch ($userFilters->tags_show_by) { case 'all': $categories = Category::with(['tags' => function ($query) use($userFilters, $activityOfTagsLimitInDays) { if ($userFilters->tags_unactives == 'exclude') { $query->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } }, 'tags.topics'])->get(); break; case 'official': $categories = Category::with(['tags' => function ($query) use($userFilters, $activityOfTagsLimitInDays) { $query->where('is_official', true); if ($userFilters->tags_unactives == 'exclude') { $query->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } }])->get(); break; case 'unofficial': $categories = Category::with(['tags' => function ($query) use($userFilters, $activityOfTagsLimitInDays) { $query->where('is_official', false); if ($userFilters->tags_unactives == 'exclude') { $query->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } }, 'tags.topics'])->get(); break; } /** * Filtering the Categories to exclude all the empty ones. */ $filteredCategories = $categories->reject(function ($category) { return $category->tags->isEmpty(); })->all(); /** * Clearing each Category to exclude empty Tags. */ foreach ($filteredCategories as $category) { $category->clearedTags = $category->tags->reject(function ($tag) { return $tag->topics->isEmpty(); })->all(); } /** * Returning the view with the parameters. */ return view('forum.index')->with(['categories' => $filteredCategories, 'isClassicDisplay' => true, 'tagFilters' => $tagFilters, 'userFilters' => $userFilters]); /** * Get to the other Case. */ break; /** * Displaying by popularity. * * We show the tags ordering them by the amount of posts they contain. */ /** * Displaying by popularity. * * We show the tags ordering them by the amount of posts they contain. */ case 'popular': /** * Selecting the Tags following the filters applied by the user. */ switch ($userFilters->tags_show_by) { case 'all': $tags = Tag::with('topics'); if ($userFilters->tags_unactives == 'exclude') { $tags->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } $tags = $tags->get(); break; case 'official': $tags = Tag::with('topics')->where('is_official', true); if ($userFilters->tags_unactives == 'exclude') { $tags->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } $tags = $tags->get(); break; case 'unofficial': $tags = Tag::with('topics')->where('is_official', false); if ($userFilters->tags_unactives == 'exclude') { $tags->where('updated_at', '>', Carbon::now()->subDays($activityOfTagsLimitInDays)); } $tags = $tags->get(); break; } /** * Filtering the Tags to exclude all the empty ones and ordering them by activity. */ $filteredTags = $tags->reject(function ($tag) { return $tag->topics->isEmpty(); })->sortByDesc(function ($tag) { return $tag->topics->count(); })->all(); /** * Returning the view with the parameters. */ return view('forum.index')->with(['filteredTags' => $filteredTags, 'isClassicDisplay' => false, 'tagFilters' => $tagFilters, 'userFilters' => $userFilters]); /** * The end. */ break; } }