Exemplo n.º 1
0
 public function store(CustomFieldRequest $request, CustomField $custom_field)
 {
     if (!Entrust::can('manage_custom_field')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $data = $request->all();
     $custom_field->fill($data);
     $field_value = explode(',', $request->input('field_value'));
     $field_value = array_unique($field_value);
     $custom_field->field_values = implode(',', $field_value);
     $custom_field->field_name = Helper::createSlug($request->input('field_title'));
     $custom_field->save();
     $activity = 'New Custom Field "' . $request->input('field_title') . '" added';
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.ADDED'));
 }
Exemplo n.º 2
0
 public function store(NewTemplateRequest $request)
 {
     $template_subject = Helper::createSlug($request->input('template_subject'));
     $templates = Helper::getTemplate();
     if (array_key_exists($template_subject, $templates)) {
         return redirect()->back()->withErrors('This template already exists.');
     }
     if ($request->input('category') == 'user') {
         $fields = 'CURRENT_DATE_TIME,CURRENT_DATE,NAME,USERNAME,EMAIL';
     } elseif ($request->input('category') == 'ticket') {
         $fields = 'CURRENT_DATE_TIME, CURRENT_DATE, TICKET_NO, DEPARTMENT, TICKET_SUBJECT, TICKET_STATUS, TICKET_PRIORITY, TICKET_TYPE, USERNAME, NAME, EMAIL, RESPONSE_TIME, RESOLUTION_TIME';
     } else {
         $fields = '';
     }
     $templates[$template_subject] = array('title' => Helper::toWord($template_subject), 'fields' => $fields, 'category' => $request->input('category'));
     $filename = base_path() . '/config/template.php';
     File::put($filename, var_export($templates, true));
     File::prepend($filename, '<?php return ');
     File::append($filename, ';');
     return redirect()->back()->withSuccess('Template added.');
 }
Exemplo n.º 3
0
 public function update(PageRequest $request, Page $page)
 {
     if (!Entrust::can('edit_page')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $data = $request->all();
     $page->fill($data);
     $page->page_slug = Helper::createSlug($data['page_title']);
     $page->save();
     Helper::updateCustomField($this->form, $page->id, $data);
     $activity = 'Edit a page';
     Activity::log($activity);
     return redirect('/page')->withSuccess(config('constants.SAVED'));
 }