本文整理汇总了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();
}
示例2: get
public function get($id)
{
$article = Tag::with('articles.tags')->find($id);
if (!$article) {
return response()->json(null, 404);
}
return response()->json($article);
}
示例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();
}
示例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'));
}
示例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]);
}
}
示例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'));
}
示例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]]);
}
示例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();
}
示例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);
}
示例10: showEntriesByTag
public function showEntriesByTag($id)
{
$tag = Tag::with('entries')->where('id', '=', $id)->first();
return view('tag.entries', compact('tag'));
}
示例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')));
}
示例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);
}
示例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'));
}
示例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);
}
示例15: index
public function index()
{
$posts = Post::with('tags')->orderBy('id')->get();
$tags = Tag::with('posts')->get();
return view('admin.index', compact('posts', 'tags'));
}