public function listing(LanguageRequest $request)
 {
     $page = $request->input('page');
     $limit = $request->input('limit');
     $resp = $this->repo->listing($page, $limit);
     if (!empty($resp)) {
         return response()->json(['status' => 'success', 'data' => $resp, 'code' => 200], 200);
     }
 }
 /**
  * Save image to uploads folder and change the name to something unique
  *
  * @param LanguageRequest $request
  * @param $field
  * @return array
  */
 private function storeImage(LanguageRequest $request, $field)
 {
     $data = $request->except([$field]);
     if ($request->file($field)) {
         $file = $request->file($field);
         $request->file($field);
         $fileName = rename_file($file->getClientOriginalName(), $file->getClientOriginalExtension());
         $path = '/uploads/' . str_plural($field);
         $move_path = public_path() . $path;
         $file->move($move_path, $fileName);
         $data[$field] = $path . $fileName;
     }
     return $data;
 }
Esempio n. 3
0
 public function store(LanguageRequest $request)
 {
     if (!Entrust::can('manage_language')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $languages = Helper::getAllLanguages();
     $locale = $request->input('locale');
     $name = $request->input('name');
     if (array_key_exists($locale, $languages) || in_array($name, $languages)) {
         return redirect()->back()->withErrors('This language is already added.');
     }
     $languages[$locale] = $name;
     $filename = base_path() . config('paths.LANG_PATH');
     File::put($filename, var_export($languages, true));
     File::prepend($filename, '<?php return ');
     File::append($filename, ';');
     if (!file_exists(base_path() . '/resources/lang/' . $locale)) {
         $result = File::makeDirectory(base_path() . '/resources/lang/' . $locale);
     }
     if (!File::exists(base_path() . '/resources/lang/' . $locale . '/messages.php')) {
         File::put(base_path() . '/resources/lang/' . $locale . '/messages.php', '<?php return array();');
     }
     $activity = 'Added new Language';
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.ADDED'));
 }