本文整理汇总了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'));
}
示例2: getCraftsByTag
public function getCraftsByTag()
{
$tag = Tag::with('crafts')->find($this->id);
$relations = $tag->getRelations();
$crafts = $relations['crafts'];
return $crafts;
}
示例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'));
}
示例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);
}
示例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]);
}
}
示例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'));
}
示例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'));
}
示例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);
}