public function storeRequest($vks_id) { try { $vks = Vks::with('tech_support_requests')->findOrFail($vks_id); } catch (Exception $e) { $this->error('404'); } $request = $this->request->request; $this->validator->validate(['Сообщение' => [$request->get('user_message'), 'max(255)'], 'Точка' => [$request->get('att_id'), 'required|int']]); //if no passes if (!$this->validator->passes()) { $this->backWithData($this->validator->errors()->all()); } $request_new = new TechSupportRequest(array('att_id' => $request->get('att_id'), 'vks_id' => $vks->id, 'owner_id' => App::$instance->user->id, 'user_message' => $request->get('user_message'), 'status' => $vks->status == VKS_STATUS_APPROVED ? TechSupportRequest::STATUS_READY_FOR_SEND : TechSupportRequest::STATUS_WAIT_VKS_DECISION)); $flag = false; if (count($vks->tech_support_requests)) { foreach ($vks->tech_support_requests as $request) { if ($request_new->att_id == $request->att_id) { $flag = true; } } } if (!$flag) { $request_new->save(); } App::$instance->MQ->setMessage("Запрос успешно создан"); ST::redirectToRoute('TechSupport/showRequests/' . $vks->id); }
public function isCodeInUse($code, $period_start, $period_end, $force_no_ajax = false) { $use = false; $period_start = $period_start instanceof DateTime ? $period_start : date_create($period_start); $period_end = $period_end instanceof DateTime ? $period_end : date_create($period_end); // dump($period_start, $period_end); $vc = new Vks_controller(); //how much digits in num $digits = strlen((string) $code); $vkses = Vks::with('connection_codes')->where('start_date_time', '<=', $period_end->modify("+" . Settings_controller::getOther('pause_gap') . " minutes"))->where('end_date_time', '>=', $period_start->modify("-" . Settings_controller::getOther('pause_gap') . " minutes"))->approved()->get(['id', 'title', 'start_date_time', 'end_date_time', 'date']); // dump($vkses); foreach ($vkses as $vks) { if (count($vks->connection_codes)) { foreach ($vks->connection_codes as $vcode) { if (substr($vcode->value, -$digits) == $code) { $vks = $vc->humanize($vks); $use = $vks; break; } } } } if ($force_no_ajax) { return $use; } // ST::makeDebug($use); if (ST::isAjaxRequest()) { if ($use) { $use = $use->toJson(); } print json_encode($use); } else { return $use; } }
public function showLocalVks($caVksId) { Auth::isAdminOrDie(App::$instance); $vkses = Vks::with('participants')->where('link_ca_vks_id', $caVksId)->get(); foreach ($vkses as $vks) { $this->humanize($vks); } $this->render('Vks/showLocalRelativeToCa', compact('vkses', 'caVksId')); }