public function fire() { $api = new Api(); $list = $api->PriceList(); $listGroup1 = []; $listGroup2 = []; $listGroup3 = []; foreach ($list as &$item) { foreach ($item as &$val) { $val = trim(urldecode($val)); } if ($item->group_p && !in_array($item->group_p, $listGroup1)) { $listGroup1[] = $item->group_p; } if ($item->group_c && !in_array($item->group_c, $listGroup2)) { $listGroup2[] = $item->group_c; } if ($item->top_parent && !in_array($item->top_parent, $listGroup3)) { $listGroup3[] = $item->top_parent; } } foreach ($list as $item) { $title = ServiceTitle::whereAgbisId($item->id)->first(); if (!$title) { $title = new ServiceTitle(); } $title->agbis_id = $item->id; $title->code = $item->code; $title->name = $item->name; $lang = !empty($title->lang) ? json_decode($title->lang) : (object) []; $lang->ru = $item->name; $title->lang = json_encode($lang, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $title->save(); } }
public function update($id) { $text = Input::get('content'); $lang = Input::get('lang'); $title = ServiceTitle::findOrFail($id); $langContent = $title->lang; $langContent = $langContent ? json_decode($langContent) : (object) []; $langContent->{$lang} = $text; $title->lang = json_encode($langContent, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $title->save(); }
/** * подробный список услуг в заказе * * @param $id * * @return \Illuminate\View\View */ public function orderServices($id) { try { $os = new OrderServiceComponent(); $services = $os->parseOrderService($id); $showButton = true; if (PaymentCloud::checkPaid($id)) { $showButton = false; } $total = 0; foreach ($services as $service) { $total += $service['amount']; } // если не русский, будем переводить if (App::getLocale() != 'ru') { foreach ($services as &$item) { $title = ServiceTitle::whereName($item['name'])->first(); if ($title) { $item['name'] = $title->lang(App::getLocale()); } } } } catch (ApiException $e) { return $this->responseException($e, true); } return View::make('ac::order', ['services' => $services, 'id' => $id, 'showButton' => $showButton, 'total' => $total]); }