本文整理匯總了PHP中app\models\Menu::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP Menu::count方法的具體用法?PHP Menu::count怎麽用?PHP Menu::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Menu
的用法示例。
在下文中一共展示了Menu::count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postCreate
public function postCreate()
{
$validator = Validator::make(Input::all(), Menu::$rules);
if ($validator->passes()) {
$menu = new Menu();
$menu->title = Input::get('title');
$menu->url = Input::get('url');
$menu->weight = Menu::count();
$menu->save();
return Redirect::back()->with('message', "Элемент меню добавлен");
}
return Redirect::back()->with('message', "Ошибка");
}
示例2: uploadMenu
public function uploadMenu(Request $request)
{
$data = $this->postUpload($request);
if (is_array($data)) {
$before = Menu::count();
foreach ($data as $item) {
Menu::updateOrCreate(['number' => $item['number']], ['number' => $item['number'], 'title' => $item['title'], 'price' => $item['price']]);
}
$difference = Menu::count() - $before;
Helper::add('', 'uploaded menu items import file');
if ($difference > 0) {
Session::flash('flash_message', $difference . ' ' . $this->title . ' items successfully imported!');
} else {
Session::flash('flash_message', 'No new ' . $this->title . ' items imported!');
}
return Redirect::action('MenusController@index');
} else {
return $data;
}
}
示例3: uploadMenu
public function uploadMenu(Request $request)
{
$data = $this->postUpload($request);
if (is_array($data)) {
$before = Menu::count();
$sale = Sales::create(['stock_period_id' => $request->get('stock_period_id')]);
foreach ($data as $item) {
$menu = Menu::updateOrCreate(['number' => $item['number']], ['number' => $item['number'], 'title' => $item['title'], 'price' => $item['price']]);
$data = ['quantity' => $item['quantity'], 'menu_id' => $menu->id, 'sale_id' => $sale->id, 'price' => $item['price'], 'total_price' => round($item['price'] * $item['quantity'], 2)];
SaleItems::create($data);
}
$difference = Menu::count() - $before;
Helper::add('', 'uploaded ' . $difference . ' menu items import file on import sales action');
Session::flash('flash_message', 'Sale uploaded successfully with ' . $difference . ' new items added to menu.');
return Redirect::action('SalesController@index', ['stock_period' => $request->get('stock_period_id')]);
} else {
return $data;
}
}