Пример #1
0
 public function index()
 {
     $this->layout->with('subtitle', 'Bookings');
     $bookings = Booking::orderBy('last')->orderBy('first');
     $filtered = false;
     $filter_name = Session::get('bookings_filter_name', '');
     $filter_church = Session::get('bookings_filter_church', '');
     $filter_eventbrite = Session::get('bookings_filter_eventbrite', '');
     $filter_registered = Session::get('bookings_filter_registered', '');
     $filter_not_registered = Session::get('bookings_filter_not_registered', '');
     $filter_saturday = Session::get('bookings_filter_saturday', '');
     $filter_not_saturday = Session::get('bookings_filter_not_saturday', '');
     if (!empty($filter_name)) {
         $bookings = $bookings->where(function ($query) use($filter_name) {
             $query->where('bookings.first', 'LIKE', "%{$filter_name}%")->orWhere('bookings.last', 'LIKE', "%{$filter_name}%");
         });
         $filtered = true;
     }
     if (!empty($filter_church)) {
         $bookings = $bookings->where('source', 'Church');
         $filtered = true;
     }
     if (!empty($filter_eventbrite)) {
         $bookings = $bookings->where('source', 'EventBrite');
         $filtered = true;
     }
     if (($filter_registered || $filter_not_registered) && !($filter_registered && $filter_not_registered)) {
         if ($filter_registered) {
             $ids = DB::table('booking_registration_counts')->whereRaw('tickets <= registrations')->lists('id');
             if ($ids) {
                 $bookings = $bookings->whereIn('id', $ids);
             }
         } else {
             $ids = DB::table('booking_registration_counts')->whereRaw('tickets > registrations')->lists('id');
             if ($ids) {
                 $bookings = $bookings->whereIn('id', $ids);
             }
         }
     }
     if (($filter_saturday || $filter_not_saturday) && !($filter_saturday && $filter_not_saturday)) {
         if ($filter_saturday) {
             $bookings = $bookings->where('saturday', true);
         } else {
             $bookings = $bookings->where('saturday', false);
         }
         $filtered = true;
     }
     $bookings = $bookings->paginate(25);
     $this->layout->content = View::make('bookings.index')->with('bookings', $bookings)->with('filtered', $filtered)->with('filter_name', $filter_name)->with('filter_church', $filter_church)->with('filter_eventbrite', $filter_eventbrite)->with('filter_registered', $filter_registered)->with('filter_not_registered', $filter_not_registered)->with('filter_saturday', $filter_saturday)->with('filter_not_saturday', $filter_not_saturday);
 }
 public function getManage()
 {
     return View::make('bookings.manage')->with('bookings', Booking::orderBy('created_at', 'DESC')->paginate(10));
 }