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


PHP Tag::with方法代码示例

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


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

示例1: tags

 public function tags($id)
 {
     $tag = Tag::find($id);
     $posts = $tag->posts()->get();
     $tags = Tag::with('posts')->paginate(8);
     return View::make('search', compact('posts', 'tags'));
 }
开发者ID:mkwarren21,项目名称:blog.dev,代码行数:7,代码来源:HomeController.php

示例2: getCraftsByTag

 public function getCraftsByTag()
 {
     $tag = Tag::with('crafts')->find($this->id);
     $relations = $tag->getRelations();
     $crafts = $relations['crafts'];
     return $crafts;
 }
开发者ID:rituzy,项目名称:iblog,代码行数:7,代码来源:Tag.php

示例3: create

 /**
  * Show the form for creating a new qa
  *
  * @return Response
  */
 public function create()
 {
     $converter = new CommonMarkConverter();
     $tags = Tag::with('tutorials', 'qas')->get();
     // return View::make('qas.create');
     return View::make('qas.create', compact('tags', 'converter'));
 }
开发者ID:automotivecapstone,项目名称:capstone.dev,代码行数:12,代码来源:QasController.php

示例4: displayPostsByTag

 public function displayPostsByTag($id)
 {
     $postViews = array();
     $posts = Tag::with('posts', 'posts.author', 'posts.tags')->find($id)->posts;
     foreach ($posts as $post) {
         Log::debug('Rendering a post: Title = ' . $post->title . '; Author = ' . $post->author->name . '; Created at = ' . $post->created_at . '; Tags:');
         foreach ($post->tags as $tag) {
             Log::debug('Tag = ' . $tag->name);
         }
         $postView = View::make('post')->with('post', $post)->with('author', $post->author)->with('tags', $post->tags);
         array_push($postViews, $postView);
     }
     return View::make('home')->with('posts', $postViews);
 }
开发者ID:ahumellihuk,项目名称:blogging-platform,代码行数:14,代码来源:HomeController.php

示例5: index

 /**
  * Display a listing of tags
  *
  * @return Response
  */
 public function index()
 {
     $search = Input::get('search');
     if ($search) {
         $query = Tag::with('user')->where('title', 'LIKE', '%' . $search . '%')->orWhere('body', 'LIKE', '%' . $search . '%');
     } else {
         $query = Tag::with('user');
     }
     $query = $query->orderBy('created_at', 'desc');
     if (Request::wantsJson()) {
         $tags = $query->get();
         return Response::json(['tags' => $tags]);
     } else {
         $tags = $query->paginate(4);
         return View::make('tags.index')->with(['tags' => $tags, 'search' => $search]);
     }
 }
开发者ID:automotivecapstone,项目名称:capstone.dev,代码行数:22,代码来源:TagsController.php

示例6: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($slug)
 {
     $tags = Tag::with('posts')->get();
     $post = Post::where('slug', $slug)->first();
     return View::make('posts.edit', compact('post', 'tags'));
 }
开发者ID:mkwarren21,项目名称:blog.dev,代码行数:12,代码来源:PostsController.php

示例7: edit

 /**
  * Show the form for editing the specified resource.
  * GET /user/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (Auth::id() != $id) {
         Log::info('This user id is not equal');
         return Redirect::action('UsersController@show', Auth::id());
     }
     $tags = Tag::with('tutorials', 'qas')->get();
     $user = User::find($id);
     return View::make('users.edit', compact('user', 'tags'));
 }
开发者ID:automotivecapstone,项目名称:capstone.dev,代码行数:17,代码来源:UsersController.php

示例8: show

 /**
  * Display the specified resource.
  *
  * @param  string $name Tag name
  * @return Response
  */
 public function show($name)
 {
     // get tag by tag name, eager load posts
     $tag = Tag::with('posts')->where('name', 'like', $name)->first();
     $this->layout->content = View::make('tag.show')->with('tag', $tag);
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:12,代码来源:TagController.php


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