<?php return array('fields' => function () { /** * Предзагружаем нужные словари с данными, по системному имени словаря, для дальнейшего использования. * Делается это одним SQL-запросом, для снижения нагрузки на сервер БД. */ $dics_slugs = array('city', 'course'); $dics = Dic::whereIn('slug', $dics_slugs)->with('values')->get(); $dics = Dic::modifyKeys($dics, 'slug'); #Helper::tad($dics); $lists = Dic::makeLists($dics, 'values', 'name', 'id'); #Helper::dd($lists); $lists_ids = Dic::makeLists($dics, null, 'id', 'slug'); #Helper::dd($lists_ids); return array('company' => array('title' => 'Компания', 'type' => 'text'), 'position' => array('title' => 'Должность', 'type' => 'text'), 'quote' => array('title' => 'Цитата в шапке', 'type' => 'textarea'), 'header_img' => array('title' => 'Изображение в шапке', 'type' => 'image', 'params' => array('maxFilesize' => 4)), 'avatar' => array('title' => 'Аватар', 'type' => 'image', 'params' => array('maxFilesize' => 4)), 'gender' => array('title' => 'Пол', 'type' => 'select', 'values' => Config::get('site.genders')), 'short' => array('title' => 'Короткий текст', 'type' => 'textarea'), 'full' => array('title' => 'Полный текст', 'type' => 'textarea_redactor'), 'city_id' => array('title' => 'Город', 'type' => 'select', 'values' => $lists['city'], 'default' => Input::get('filter.fields.city_id') ?: null), 'course_id' => array('title' => 'Обучался на курсе', 'type' => 'select', 'values' => array('Выберите..') + $lists['course'], 'default' => Input::get('filter.fields.course_id') ?: null), '-' => array('type' => 'custom', 'content' => '<br/><strong>ИЛИ</strong><br/><br/>'), 'course_text' => array('title' => 'Название курса', 'type' => 'text'), 'fb_link' => array('title' => 'Facebook', 'type' => 'text', 'others' => ['placeholder' => 'http://']), 'vk_link' => array('title' => 'VKontakte', 'type' => 'text', 'others' => ['placeholder' => 'http://']), 'ig_link' => array('title' => 'Instagram', 'type' => 'text', 'others' => ['placeholder' => 'http://']), 'tw_link' => array('title' => 'Twitter', 'type' => 'text', 'others' => ['placeholder' => 'http://']), 'yt_link' => array('title' => 'YouTube', 'type' => 'text', 'others' => ['placeholder' => 'http://']), 'mainpage' => array('no_label' => true, 'title' => 'Показывать на главной', 'type' => 'checkbox', 'label_class' => 'normal_checkbox')); }, 'hooks' => array('after_store_update_destroy_order' => function ($dic = NULL, $dicval = NULL) { Cache::forget('dic_' . $dic->slug); }));
public function postAjaxOrderSave() { $poss = Input::get('poss'); $pls = Dic::whereIn('id', $poss)->get(); if ($pls) { foreach ($pls as $pl) { $pl->order = array_search($pl->id, $poss); $pl->save(); } } return Response::make('1'); }
<a href="' . URL::route('entity.index', array('lessons', 'filter[fields][course_id]' => $dicval->id)) . '" class="btn btn-default"> Программа курса (' . @(int) $counts[$dicval->id][$dic_lessons->id] . ') </a> </span> <span class="block_ margin-bottom-5_"> <a href="' . URL::route('entity.index', array('reviews', 'filter[fields][course_id]' => $dicval->id)) . '" class="btn btn-default"> Отзывы (' . @(int) $counts[$dicval->id][$dic_reviews->id] . ') </a> </span> '; }, 'hooks' => array('before_index_view' => function ($dic, $dicvals) { /** * Предзагружаем нужные словари */ $dics_slugs = array('city', 'type', 'lessons', 'reviews'); $dics = Dic::whereIn('slug', $dics_slugs)->with('values_no_conditions')->get(); $dics = Dic::modifyKeys($dics, 'slug'); #Helper::tad($dics); Config::set('temp.index_dics', $dics); ## Получаем список с нужными индексами $cities = Dic::makeLists($dics['city']['values_no_conditions'], null, 'name', 'id'); #Helper::ta($cities); Config::set('temp.cities', $cities); ## Получаем список с нужными индексами $types = Dic::makeLists($dics['type']['values_no_conditions'], null, 'name', 'id'); #Helper::ta($types); Config::set('temp.types', $types); /** * Создаем списки из полученных данных */ $dic_ids = Dic::makeLists($dics, false, 'id');
Продукция (' . @(int) $counts[$dicval->id][$dic_products->id] . ') </a> <a href="' . URL::route('entity.index', array('interiors', 'filter[fields][collection_id]' => $dicval->id)) . '" class="btn btn-default"> Интерьеры (' . @(int) $counts[$dicval->id][$dic_interiors->id] . ') </a> </span> '; }, 'hooks' => array('before_all' => function ($dic) { }, 'before_index' => function ($dic) { }, 'before_index_view_create_edit' => function ($dic, $dicvals = null, $dicval = null) { }, 'before_index_view' => function ($dic, $dicvals) { /** * Предзагружаем нужные словари */ $dics_slugs = array('products', 'interiors'); $dics = Dic::whereIn('slug', $dics_slugs)->get(); $dics = Dic::modifyKeys($dics, 'slug'); #Helper::tad($dics); Config::set('temp.index_dics', $dics); /** * Создаем списки из полученных данных */ $dic_ids = Dic::makeLists($dics, false, 'id'); #Helper::d($dic_ids); $dicval_ids = Dic::makeLists($dicvals, false, 'id'); #Helper::d($dicval_ids); /** * Получаем количество необходимых нам данных, одним SQL-запросом. * Сохраняем данные в конфиг - для дальнейшего использования в функции-замыкании actions (см. выше). */ $counts = array();