Esempio n. 1
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
         $rules['title_' . $short] = 'required|min:1|max:254';
     }
     $rules['sort'] = 'digits_between:1,100000';
     return $rules;
 }
Esempio n. 2
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $rules = ['active' => 'boolean'];
     foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
         $rules['title_' . $short] = 'required|min:2|max:254';
         //            $rules['description_' . $short] = 'required';
     }
     $rules['sort'] = 'digits_between:1,100000';
     return $rules;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \App\Http\Requests\OptionRequest $request
  * @param \App\Criteria $criteria
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\OptionRequest $request, Criteria $criteria)
 {
     DB::transaction(function () use($criteria, $request) {
         $option = $criteria->options()->create(['sort' => $request->get('sort')]);
         $langs = [];
         foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
             $langs[] = ['lang_id' => dbTrans($short), 'title' => $request->get('title_' . $short)];
         }
         $option->langs()->createMany($langs);
     });
     return redirect(action('Admin\\CriteriaOptionController@index', [$criteria->id]))->with('success', 'saved');
 }
Esempio n. 4
0
 public function getFields()
 {
     $languages = LaravelLocalization::getSupportedLocales();
     foreach ($languages as $locale => $value) {
         $content = $this->getFormContent($locale)->content;
         //FormbuilderShortcode::registerShortcode();
         $shortcodes = Shortcode::all();
         $pattern = $this->getRegex($shortcodes);
         preg_replace_callback("/{$pattern}/s", [&$this, 'getFieldsData'], $content);
     }
     $fields = $this->fieldsDatas;
     return $fields;
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \App\Http\Requests\NewsRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\NewsRequest $request)
 {
     $departmentId = auth()->user()->department_id;
     if ($request->has('department_id') && $this->systemAdmin) {
         $departmentId = $request->get('department_id');
     }
     DB::transaction(function () use($departmentId, $request) {
         $news = News::create(['department_id' => $departmentId, 'active' => $request->get('active'), 'sort' => $request->get('sort')]);
         $langs = [];
         foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
             $langs[] = ['lang_id' => dbTrans($short), 'title' => $request->get('title_' . $short), 'description' => $request->get('description_' . $short)];
         }
         $news->langs()->createMany($langs);
     });
     return redirect(action('Admin\\NewsController@index'))->with('success', 'saved');
 }
Esempio n. 6
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $imageMax = 1024;
     $rules = ['keyword' => [1 => 'required', 2 => 'max:6', 3 => 'unique:department,keyword', 4 => 'regex:' . config('app.expressions.dir')], 'image' => 'required|image|max:' . $imageMax, 'theme_background_color' => 'required', 'theme_color' => 'required', 'sort' => 'digits_between:1,100000'];
     foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
         $rules['name_' . $short] = 'required|min:2|max:100';
         $rules['title_' . $short] = 'required|min:2|max:254';
         $rules['description_' . $short] = 'required|min:2|max:100';
     }
     $id = $this->request->get('id');
     if ($id) {
         #update request
         $rules['keyword'][3] .= ',' . $id;
         if (!$this->request->get('image')) {
             $rules['image'] = '';
         }
     }
     return $rules;
 }
Esempio n. 7
0
 /**
  * Set entity data.
  *
  * @param null $default
  */
 public function init($default = null)
 {
     $this->request = $default;
     $locale = $this->locale;
     $entityItem = $this->entity;
     $type = $this->type;
     if (isset($locale)) {
         $entity = new Entity($entityItem->id, $entityItem->template, $locale, $type);
         $entity->init($default);
         $this->entities[$locale] = $entity;
     } else {
         $languages = LaravelLocalization::getSupportedLocales();
         foreach ($languages as $locale => $code) {
             $entity = new Entity(@$entityItem->id, @$entityItem->template, $locale, $type);
             $entity->init($default);
             $this->entities[$locale] = $entity;
         }
     }
 }
 private function addDepartmentLangs(Requests\DepartmentRequest $request, Department $department)
 {
     $langs = [];
     foreach (LaravelLocalization::getSupportedLocales() as $short => $locale) {
         $langs[] = ['lang_id' => dbTrans($short), 'name' => $request->get('name_' . $short), 'title' => $request->get('title_' . $short), 'description' => $request->get('description_' . $short)];
     }
     $department->langs()->createMany($langs);
 }
Esempio n. 9
0
 /**
  * @return \Illuminate\Support\Collection
  */
 public function requiredLocales()
 {
     return LaravelLocalization::getSupportedLocales();
 }
 /**
  * @return \Illuminate\Http\JsonResponse
  */
 public function ajaxRender()
 {
     $this->assetPipeline->requireJs('ckeditor.js');
     $request = BaseRequest::all();
     $template = $request['template'];
     $entityType = $request['entity_type'];
     $id = $request['id'];
     $entity = new $entityType();
     if (get_class($entity) == "stdClass") {
         $entity->id = null;
     } else {
         $entity = $entity->firstOrNew(['id' => $id]);
     }
     $entity->template = $template;
     $advanceFields = new DynamicFields($entity);
     $advanceFields->init();
     $locale = array_keys(LaravelLocalization::getSupportedLocales());
     $jsonData = array();
     foreach ($locale as $v) {
         $jsonData['html'][$v] = $advanceFields->renderFields($v);
     }
     $jsonData['locale'] = $locale;
     return response()->json($jsonData);
 }