本文整理汇总了PHP中app\Menu::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::count方法的具体用法?PHP Menu::count怎么用?PHP Menu::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Menu
的用法示例。
在下文中一共展示了Menu::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApimenulist
/**
* 菜单列表的api
*
* @param
*
* @author wen.zhou@bioon.com
*
* @date 2015-10-17 00:44:34
*
* @return
*/
public function getApimenulist(MenuContract $menuCon)
{
/*获取参数*/
$draw = request('draw', 1);
$start = request('start', 0);
$length = request('length', 10);
$search = request('search.value', '');
/*获取菜单*/
$obj_menus = new Menu();
$count = $obj_menus->count();
$obj_menus = $obj_menus->with('parentmenu')->where('parent_id', '=', '1');
$filterCount = $obj_menus->count();
if (!empty($search)) {
$obj_menus = $obj_menus->where('name', 'like', "%{$search}%");
}
/*分页*/
if ($length != -1) {
$obj_menus = $obj_menus->offset($start)->limit($length);
}
$result_menus = $obj_menus->get();
$menus = $result_menus->toArray();
foreach ($result_menus as $key => $result_menu) {
$menus[$key]['update'] = $this->current_user->can('update.menus');
$menus[$key]['delete'] = $this->current_user->can('delete.menus');
}
$returnData = ["draw" => $draw, "recordsTotal" => $count, "recordsFiltered" => $filterCount, 'data' => $menus];
return response()->json($returnData);
}