本文整理汇总了PHP中Menu::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::where方法的具体用法?PHP Menu::where怎么用?PHP Menu::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasChildItems
/**
* @param $id
*
* @return bool
*/
public function hasChildItems($id)
{
$count = $this->menu->where('parent_id', $id)->where('is_published', 1)->where('lang', $this->getLang())->get()->count();
if ($count === 0) {
return false;
}
return true;
}
示例2: index
function index()
{
$menus = new Menu();
if (@$_GET['status']) {
$menus->where('status', $_GET['status']);
}
$data['menus'] = $menus->order_by('orderlist', 'asc')->get_page(limit());
$this->template->append_metadata(js_checkbox('approve'));
$this->template->build('admin/menu_index', $data);
}
示例3: destroy
public function destroy($id)
{
Menu::destroy($id);
$child_menu_items = Menu::where('parent_id', '=', $id)->get();
foreach ($child_menu_items as $menu_items) {
$menu_items->parent_id = NULL;
$menu_items->save();
}
return Redirect::to('admin/menu')->with(array('note' => 'Successfully Deleted Menu Item', 'note_type' => 'success'));
}
示例4: menuReorder
public function menuReorder()
{
$ajax = Request::ajax();
$arrPost = Input::all();
unset($arrPost['_token']);
$updated = false;
if (!empty($arrPost)) {
$frontend = Permission::can($this->layout->admin, 'menusfrontend_edit_all');
$backend = Permission::can($this->layout->admin, 'menusbackend_edit_all');
foreach ($arrPost as $type => $menu) {
if (empty($menu)) {
continue;
}
if ($type == 'backend' && !$backend) {
continue;
} else {
if (in_array($type, ['header', 'footer']) && !$frontend) {
continue;
}
}
$menu = json_decode($menu);
foreach ($menu as $key => $value) {
$i = 1;
Menu::where('id', $value->id)->update(['parent_id' => 0, 'order_no' => $key + 1, 'level' => $i]);
if (isset($value->children)) {
Menu::updateRecursiveChildOrder($value->children, $value->id, $i + 1);
}
}
$updated = true;
}
if ($updated) {
Menu::clearCache();
}
if ($ajax) {
if ($updated) {
$sidebar = Menu::get(["sidebar" => true]);
$arrParent = Menu::getCache(['parent' => true]);
$arrReturn = ['status' => 'ok', 'sidebar' => $sidebar, 'parent' => $arrParent];
} else {
$arrReturn = ['status' => 'warning', 'message' => 'Nothing was changed.'];
}
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}
return Redirect::to(URL . '/admin/menus')->with(['flash_success' => $updated ? 'Menu has been re-ordered.' : 'Nothing was change.']);
}
if ($ajax) {
$response = Response::json(['status' => 'error', 'message' => 'We found nothing to re-order. Please check again.']);
$response->header('Content-Type', 'application/json');
return $response;
}
return Redirect::to(URL . '/admin/menus');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
$school = School::findOrFail($id);
$validator = Validator::make($data = Input::all(), School::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$school->update($data);
return Redirect::route('user.profile.index')->with("successMessage", "Data Sekolah Berhasil di Update")->withTitle('Profile');
}
示例6: postDelete
public function postDelete()
{
$id = Input::get('delete_id');
// Find all items with the parent_id of this one and reset the parent_id to zero
$items = Menu::where('parent_id', $id)->get()->each(function ($item) {
$item->parent_id = 0;
$item->save();
});
// Find and delete the item that the user requested to be deleted
$item = Menu::find($id);
$item->delete();
return Redirect::to('admin/menu');
}
示例7: create
/**
* Show the form for creating a new payment
*
* @return Response
*/
public function create()
{
$tgl = new DateTime(date('Y-m-d'));
$limit = Setting::first();
$limitdtend = new DateTime($limit->enddaypay);
$limitend = $limitdtend->diff($tgl)->format('%R%a');
$menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
$jstotal = Session::get('jstotal');
if ($limitend > 0) {
return Redirect::to('user/cost')->with('errorMessage', trans('Pembayaran Sudah Ditutup.'));
}
return View::make('payments.create')->withTitle('Payment')->with('menu', $menu)->with('jstotal', $jstotal);
}
示例8: edit_post
public function edit_post($id)
{
$valid = Validator::make(Input::all(), Order::$rule_edit_order, Order::$order_langs);
if ($valid->passes()) {
$user = User::where("username", Input::get("username"))->first();
if (count($user) == 0) {
return Redirect::route("manage_order_edit_get", $id)->withInput()->with("flash_error", "Người dùng có tên đăng nhập " . Input::get("username") . " là không tồn tại");
}
$menu = Menu::where("menu_name", Input::get("menu_name"))->first();
if (count($menu) == 0) {
return Redirect::route("manage_order_edit_get", $id)->withInput()->with("flash_error", "Thực đơn có tên " . Input::get("menu_name") . " là không tồn tại");
}
$data = array("user_id" => $user->id, "menu_id" => $menu->menu_id, "order_date" => Input::get("order_date"));
DB::table("orders")->where("order_id", $id)->update($data);
return Redirect::route("manage_order")->with("flash_success", "Chúc mừng bạn đã sửa yêu cầu thực đơn thành công");
}
return Redirect::route("manage_order_edit_get", $id)->withInput()->with("flash_error", $valid->errors()->first());
}
示例9: run
public function run()
{
$admin = Role::where('name', '=', 'admin')->firstOrFail();
$guest = Role::where('name', '=', 'guest')->firstOrFail();
$user = Role::where('name', '=', 'user')->firstOrFail();
$master = Role::where('name', '=', 'master')->firstOrFail();
Menu::create(['name' => 'home', 'description' => 'show the principal page', 'image' => '', 'title' => 'Home', 'route' => '/']);
Menu::create(['name' => 'profile', 'description' => 'provide a page to change the user profile', 'image' => '', 'title' => 'Profile', 'route' => 'profile']);
Menu::create(['name' => 'login', 'description' => 'provide a page to make a login or sign up', 'image' => '', 'title' => 'Login', 'route' => 'login']);
Menu::create(['name' => 'logout', 'description' => 'make a logout if a user is login', 'image' => '', 'title' => 'Logout', 'route' => 'logout']);
$login = Menu::where('name', '=', 'login')->firstOrFail();
$profile = Menu::where('name', '=', 'profile')->firstOrFail();
$home = Menu::where('name', '=', 'home')->firstOrFail();
$logout = Menu::where('name', '=', 'logout')->firstOrFail();
$login->roles()->attach($guest->id);
$profile->roles()->sync(array($admin->id, $user->id, $master->id));
$home->roles()->sync(array($guest->id, $admin->id, $user->id, $master->id));
$logout->roles()->sync(array($admin->id, $user->id, $master->id));
}
示例10: doOrder
public function doOrder()
{
$order = new Transaksi();
$order->username = Input::get('username');
$order->tglTransaksi = Input::get('date');
$order->location = Input::get('address');
$order->menuname = Input::get('menu');
$order->jumlahBeli = Input::get('amountOrder');
$order->idStand = Input::get('idStand');
$order->statustransaksi = Input::get('status');
$order->hargaTotal = Input::get('harga') * $order->jumlahBeli;
$order->save();
// kurangi saldo user, kurangi stok
$menuDeliver = Menu::where('name', $order->menuname)->first();
$menuDeliver->stock = $menuDeliver->stock - $order->jumlahBeli;
$userOrder = User::where('username', Session::get('user'))->first();
$userOrder->saldo = $userOrder->saldo - $order->hargaTotal;
$menuDeliver->save();
$userOrder->save();
return Redirect::to('user/admin');
}
示例11: url
<div class="row">
<div class="col-lg-12" style="margin-right:30px; margin-left:30px;">
<div class="col-lg-6">
<h1>My Menu</h1>
<div class="table-responsive">
<table class="table ">
<thead>
<tr>
<th>Menu</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<?php
$results = Menu::where('idStand', $standLoggedIn->idStand)->get();
?>
<tbody>
@foreach($results as $result)
<tr>
<td>{{$result->name}}</td>
<td>{{$result->price}}</td>
@if($result->stock >0)
<td>available</td>
@else
<td>not available</td>
@endif
<td><a class="btn btn-warning" href="{{ url() }}/vendor-admin/myMenu/{{$result->idMenu}}">Edit</a>
<a class="btn btn-danger" href="" data-toggle="modal" data-target="#myModal{{$result->idMenu}}">Delete</a></td>
<!-- modal confirm -->
示例12: edit
/**
* Show the form for editing the specified contest.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
$contest = Contest::find(Crypt::decrypt($id));
return View::make('contests.edit', compact('contest'))->withTitle('Ubah')->with('menu', $menu);
}
示例13: getMenus
/**
* 获取某个店铺的菜单
*
* 对应API:
* 请求类型:POST
* @return array 该店铺的菜单(分了类的)
*/
public function getMenus()
{
$shop_id = 1;
$result = array();
// 最终结果
$classify = self::getClassify($shop_id);
// 获取分类的数组
$result['class_num'] = count($classify);
// 分类数量
$menus = array();
foreach ($classify as $class_id => $class_name) {
$one_class = array();
$one_class['name'] = $class_name;
$one_class['menu'] = Menu::where('group_id', $class_id)->select('id', 'title', 'price', 'pic', 'sold_month', 'state', 'comment_score', 'comment_num')->get();
array_push($menus, $one_class);
}
$result['menus'] = $menus;
return $result;
}
示例14: deleteCategory
public function deleteCategory($id)
{
$category = Category::find($id);
if (!$category) {
return Redirect::back()->withErrors('Could not find category');
}
$menu = Menu::where('scat', '=', $category->name)->delete();
$category->delete();
return Redirect::back();
}
示例15: postEditMenu
public function postEditMenu($date = null)
{
if (!isset($date) or is_null($date)) {
return Redirect::to('/admin/menu');
}
$menu = Menu::where('menu_date', $date)->first();
if (is_null($menu)) {
$menu = new Menu();
}
$menu->menu_date = $date;
$menu->save();
$menu->dishes()->sync(Input::get('dishes'));
return Redirect::to('admin/menu/edit/' . $date)->with('message', "Successfully edited menu!");
}