當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。