コード例 #1
0
 /**
  * Fill attributes and save locales if exists .
  *
  * @param array $attributes
  * @return mixed
  */
 public function fill(array $attributes)
 {
     $locales = Locale\get_locales();
     foreach ($locales as $locale => $options) {
         if (in_array($locale, array_keys($attributes))) {
             $this->translations[$locale] = array_pull($attributes, $locale);
         }
     }
     return parent::fill($attributes);
 }
コード例 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $mailRow = $this->repository->find($id);
     if (!$_POST) {
         $form = FormBuilder\create_form(['action' => route('admin.mail.edit', ['id' => $id]), 'method' => FormBuilder\Form::METHOD_POST]);
         $elements[] = FormBuilder\element_text('slug', ['name' => 'slug', 'group' => 'default', 'value' => isset($mailRow->slug) ? $mailRow->slug : '']);
         if ($mailRow instanceof Translatable) {
             $locales = Locale\get_locales();
             foreach ($locales as $locale => $attributes) {
                 $translation = $mailRow->translate($locale);
                 foreach ($mailRow->translatedAttributes() as $attribute => $type) {
                     $elements[] = FormBuilder\get_element($type, ['group' => 'translations', 'label' => ucfirst($attribute) . ' ' . $locale, 'value' => isset($translation[$attribute]) ? $translation[$attribute] : '', 'name' => $locale . '[' . $attribute . ']']);
                 }
             }
         }
         $form->addElements($elements, true);
         return view('scaffold::scaffold.edit', compact('form'));
     }
     $mailRow->fill($_POST)->save();
     return back();
 }
コード例 #3
0
 /**
  * Get all locales .
  *
  * @return mixed
  */
 public function getLocales()
 {
     return Localization\get_locales();
 }