当前位置: 首页>>代码示例>>PHP>>正文


PHP Booking::whereHas方法代码示例

本文整理汇总了PHP中Booking::whereHas方法的典型用法代码示例。如果您正苦于以下问题:PHP Booking::whereHas方法的具体用法?PHP Booking::whereHas怎么用?PHP Booking::whereHas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Booking的用法示例。


在下文中一共展示了Booking::whereHas方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listAjax

 public function listAjax()
 {
     $result = array();
     $bookings = Booking::whereHas('items', function ($query) {
         $query->whereBetween('start_at', array(Input::get('start'), Input::get('end')));
     })->with('items')->get();
     foreach ($bookings as $booking) {
         //var_dump($booking->items()->count());
         foreach ($booking->items()->get() as $booking_item) {
             /** @var BookingItem $booking_item */
             $result[] = $booking_item->toJsonEvent();
         }
     }
     $start = strtotime(Input::get('start'));
     $end = strtotime(Input::get('end'));
     $i = $start;
     while ($i < $end) {
         if (!in_array(date('w', $i), array(0, 6))) {
             $result[] = $this->createBackgroundEvent($i, Config::get('booking::work_hour_start', '09:00'), Config::get('booking::work_hour_end', '18:00'));
         }
         $i += 24 * 3600;
     }
     return Response::json($result);
 }
开发者ID:urashima82,项目名称:intranet,代码行数:24,代码来源:BookingController.php

示例2: update

 /**
  * Update the specified booking in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id)
 {
     $booking = Booking::findOrFail($id);
     if (Input::has('val')) {
         $rules = ['val'];
         //dd('<pre>',Booking::with('Voucher')->where('id',$id)->first(), '</pre>');
         $bookingVouchers = Booking::whereHas('Voucher', function ($q) {
             $q->where('vouchers.val', 1);
         })->where('id', $id);
         //dd($booking->count());
         if ($bookingVouchers->count() > 0) {
             Session::flash("booking_cancellation_error_" . $id, "<b>Sorry</b>, You cannot cancel the above booking! You have " . $booking->first()->voucher->count() . " active vouchers");
         } else {
             $booking->update(array('val' => Input::get('val')));
             Session::flash('success', 'successfully Updated');
         }
         return Redirect::back();
     }
     $validator = Validator::make($data = Input::all(), Booking::$agentRules);
     if ($validator->fails()) {
         //dd($validator->errors());
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['user_id'] = Auth::id();
     $booking->update($data);
     return Redirect::back();
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:33,代码来源:BookingsController.php

示例3: getInvoices

 public function getInvoices()
 {
     $reference_number = Input::has('reference_number') ? Input::get('reference_number') : '%';
     if (Entrust::hasRole('Admin')) {
         $agent_id = Input::get('agent_id');
         $bookings = Booking::whereHas('user', function ($q) use($agent_id) {
             $q->where('users.id', 'like', '%' . $agent_id . '%');
         })->whereHas('invoice', function ($q) use($reference_number) {
             $q->where('reference_number', 'like', '%' . $reference_number . '%');
         });
     } else {
         //dd('asdasd');
         $bookings = Booking::whereHas('user', function ($q) {
             $q->where('users.id', $this->_user->id);
         })->with('invoice')->where('reference_number', 'like', '%' . $reference_number . '%');
     }
     //$bookings = Booking::with('invoice')->where('user_id',Auth::id())->get();
     if (Input::get('search')) {
         $from = Input::get('from');
         $to = Input::get('to');
         $agent_id = Input::get('agent_id');
         $bookings = $bookings->where('arrival_date', '>=', $from)->where('arrival_date', '<=', $to);
     }
     $bookings = $bookings->get();
     return View::make('accounts.invoices', compact('bookings', 'from', 'to', 'tour_type', 'status', 'reference_number'));
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:26,代码来源:AccountsController.php


注:本文中的Booking::whereHas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。