当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::with方法代码示例

本文整理汇总了PHP中app\Tag::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::with方法的具体用法?PHP Tag::with怎么用?PHP Tag::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Tag的用法示例。


在下文中一共展示了Tag::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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();
 }
开发者ID:gabrieljo,项目名称:l5essential,代码行数:7,代码来源:ArticlesController.php

示例2: get

 public function get($id)
 {
     $article = Tag::with('articles.tags')->find($id);
     if (!$article) {
         return response()->json(null, 404);
     }
     return response()->json($article);
 }
开发者ID:valiknet18,项目名称:FootballNewsApp,代码行数:8,代码来源:TagsController.php

示例3: __construct

 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();
 }
开发者ID:mwasa,项目名称:l5essential,代码行数:8,代码来源:ArticlesController.php

示例4: index

 /**
  * 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'));
 }
开发者ID:yoongkang0122,项目名称:tyloo,代码行数:13,代码来源:WorkController.php

示例5: showTag

 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]);
     }
 }
开发者ID:tianyirenjian,项目名称:laravel-blog,代码行数:10,代码来源:IndexController.php

示例6: index

 /**
  * 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'));
 }
开发者ID:nickfranciosi,项目名称:nickfranciosi.com,代码行数:15,代码来源:BlogController.php

示例7: edit

 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]]);
 }
开发者ID:Byron-Z,项目名称:LaravelProject,代码行数:11,代码来源:ArticleController.php

示例8: __construct

 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();
 }
开发者ID:linuxssm,项目名称:l5essential,代码行数:12,代码来源:ArticlesController.php

示例9: __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);
 }
开发者ID:Byron-Z,项目名称:LaravelProject,代码行数:12,代码来源:ArticleBaseController.php

示例10: showEntriesByTag

 public function showEntriesByTag($id)
 {
     $tag = Tag::with('entries')->where('id', '=', $id)->first();
     return view('tag.entries', compact('tag'));
 }
开发者ID:jeremy-breidenbach,项目名称:journalmate,代码行数:5,代码来源:TagsController.php

示例11: getTagged

 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')));
 }
开发者ID:Mohit127,项目名称:WhatTheTag,代码行数:10,代码来源:PhotoController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return \App\Tag::with(['user', 'bookmarks'])->find($id);
 }
开发者ID:telswick,项目名称:bocket,代码行数:10,代码来源:TagsController.php

示例13: index

 /**
  * 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'));
 }
开发者ID:ambarsetyawan,项目名称:laravel5-blog-1,代码行数:10,代码来源:TagsController.php

示例14: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     return \App\Tag::with(['tagBookmarks', 'users'])->find($id);
 }
开发者ID:fasteddiegarcia,项目名称:bocket,代码行数:11,代码来源:TagsController.php

示例15: index

 public function index()
 {
     $posts = Post::with('tags')->orderBy('id')->get();
     $tags = Tag::with('posts')->get();
     return view('admin.index', compact('posts', 'tags'));
 }
开发者ID:andycrockett,项目名称:andycrockett,代码行数:6,代码来源:AdminController.php


注:本文中的app\Tag::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。