本文整理汇总了PHP中app\Category::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::whereIn方法的具体用法?PHP Category::whereIn怎么用?PHP Category::whereIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::whereIn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_categories_by_parents_id_in
public function get_categories_by_parents_id_in($ids_array)
{
$category = Category::whereIn('parent_id', $ids_array)->get();
if (count($category) > 0) {
return $category->toArray();
} else {
return "";
}
}
示例2: syncCategories
public function syncCategories(array $categories)
{
Category::addNeededCategories($categories);
if (count($categories)) {
$this->categories()->sync(Category::whereIn('name', $categories)->where('user_id', $this->user_id)->lists('id')->all());
return;
}
$this->categories()->detach();
}
示例3: getCategories
public static function getCategories()
{
$posts = Post::where('lang', '=', Lang::getLocale())->where('published', '=', 1)->lists('id');
$categories = Category::whereIn('post_id', $posts)->lists('name');
return array_count_values($categories);
}
示例4: dopublish
private function dopublish(Request $request, $value)
{
$category = Category::whereIn('id', $request->ids)->update(array('is_published' => $value));
$response = ['model_type' => 'Category', 'ids' => $request->ids, 'action_type' => $value == 1 ? "Publish" : "Unpublish"];
return json_encode($response);
}