Esempio n. 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function getDay(Request $request)
 {
     $date = $request->input('date');
     $queueModel = new Queue();
     $queue = $queueModel->where('date', '=', $date)->get();
     $counts['all'] = $queue->count();
     $counts['real_queue'] = $queueModel->where('date', '=', $date)->where('is_real_queue', '=', 1)->get()->count();
     $counts['online_queue'] = $queueModel->where('date', '=', $date)->where('is_real_queue', '=', 0)->get()->count();
     $cur_settings = Current_setting::where('day_date', '=', $date)->get();
     $cur_settings->sortBy('period_start_time');
     $periods = array();
     foreach ($cur_settings as $c) {
         $check = Queue::where('start_time', '=', $c['period_start_time'])->where('date', '=', $c['day_date'])->get();
         $period['period_start_time'] = $c['period_start_time'];
         $period['period_end_time'] = $c['period_end_time'];
         $period['queue'] = $check;
         $period['count'] = $check->count();
         array_push($periods, $period);
     }
     $data['periods'] = $periods;
     $data['counts'] = $counts;
     return Response::json($data);
 }
Esempio n. 2
0
 /**
  * отримання списку періодів і стану черги на день
  * @param Queue $queueModel
  * @param Current_setting $cur_setting
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getDay(Queue $queueModel, Current_setting $cur_setting, Request $request)
 {
     //todo Зробити функціонал для оновлення інформації про чергу відносно дня.
     $queueModel = new Queue();
     $today = $request->input('date');
     $res['cur_settings'] = Current_setting::where('day_date', '=', $today)->get();
     $res['res_array'] = array();
     foreach ($res['cur_settings'] as $c) {
         $check = Queue::where('start_time', '=', $c['period_start_time'])->where('date', '=', $c['day_date'])->get();
         if ($check->count() < 4) {
             array_push($res['res_array'], 1);
         } else {
             array_push($res['res_array'], 0);
         }
     }
     return Response::json($res);
 }
Esempio n. 3
0
 public function editCurSet(Request $request)
 {
     $data = $request->all();
     $cur_set = new Current_setting();
     $date = $data['date'];
     $res = array();
     foreach ($data['p_array'] as $key => $period) {
         $period['start_time'] = $period['start_time'] . ':00';
         $period['end_time'] = $period['end_time'] . ':00';
         $check = $cur_set->where('period_start_time', '=', $period['start_time'])->where('period_end_time', '=', $period['end_time'])->where('day_date', '=', $date)->get();
         if ($check->count() > 0) {
             Current_setting::where('id', '=', $check[0]['id'])->update(['workers_number' => $period['workers_number']]);
         } else {
             Current_setting::create(['day_date' => $date, 'period_start_time' => $period['start_time'], 'period_end_time' => $period['end_time'], 'period_time' => 20, 'workers_number' => $period['workers_number']]);
         }
     }
     return Response::json($res);
 }