本文整理匯總了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);
}