示例#1
0
 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'));
 }
示例#2
0
文件: Tag.php 项目: rituzy/iblog
 public function getCraftsByTag()
 {
     $tag = Tag::with('crafts')->find($this->id);
     $relations = $tag->getRelations();
     $crafts = $relations['crafts'];
     return $crafts;
 }
 /**
  * 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'));
 }
 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);
 }
 /**
  * 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]);
     }
 }
示例#6
0
 /**
  * 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'));
 }
 /**
  * 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'));
 }
 /**
  * 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);
 }