本文整理汇总了PHP中app\models\Tag::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::with方法的具体用法?PHP Tag::with怎么用?PHP Tag::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($tagID)
{
$tagID = json_decode($tagID);
$count = (bool) \Input::get('count');
if (is_array($tagID)) {
$tags = Cache::remember('tags_' . json_encode($tagID), 15, function () use($tagID) {
return Tag::with('posts')->whereIn('id', $tagID)->get();
});
} else {
$tags = array(Cache::remember('tag_' . $tagID, 15, function () use($tagID) {
return Tag::with('posts')->find($tagID);
}));
}
if ($count) {
for ($i = 0; $i < count($tags); $i++) {
$tags[$i]->count = count($tags[$i]->posts);
unset($tags[$i]->posts);
}
}
return self::makeResponse($tags);
}
示例2: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$categories = Category::with('translations')->get();
$amenities = Tag::with('translations')->get();
return view('dashboard.spaces.create', compact('categories', 'amenities'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$model = Tag::with('posts')->get()->toArray();
return response()->json(['error' => false, 'data' => ['tags' => $model, 'counts' => count($model)]], 200);
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$venue = Venue::where('id', $id)->first();
$categories = Category::with('translations')->get();
$amenities = Tag::with('translations')->get();
return view('dashboard.venues.edit', compact('venue', 'categories', 'amenities'));
}
示例5: index
public function index($id)
{
$g = Tag::with('groups')->find($id)->toArray();
dd($g);
}