示例#1
0
 public function translate_file($code, $file)
 {
     /*
     	- This function will get all rows in English file
     	- Compare with the language need to translate
     */
     $folder = base_path() . '/resources/lang/';
     $lang_folder = $folder . $code;
     if (Request::isMethod('get')) {
         $lang_name = Language::where('code', $code)->first();
         $en_rows = file_get_contents($folder . 'en/' . $file);
         $check_exist_new_file = file_exists($folder . $code . '/' . $file);
         if (!$check_exist_new_file) {
             fopen($lang_folder . '/' . $file, "w");
         }
         $lang_rows = file_get_contents($folder . $code . '/' . $file);
         /// regex english
         preg_match('/\\[(.*)\\]/is', $en_rows, $en_each_row);
         $row = explode("\n", trim($en_each_row[1]));
         foreach ($row as $key => $value) {
             $remove_phay = str_replace("'", '', $value);
             $temp = str_replace(",", '', $remove_phay);
             $split_row[] = explode('=>', $temp);
         }
         // regex lang
         $regex_lang = preg_match('/\\[(.*)\\]/is', $lang_rows, $lang_each_row);
         if ($regex_lang) {
             $row_lang = explode("\n", trim($lang_each_row[1]));
             foreach ($row_lang as $key_lang => $value_lang) {
                 $remove_phay_lang = str_replace("'", '', $value_lang);
                 $temp_lang = str_replace(",", '', $remove_phay_lang);
                 $split_row_lang[] = explode('=>', $temp_lang);
             }
         } else {
             $split_row_lang = null;
         }
         return view('admin.language.translate-file', array('lang_name' => $lang_name, 'rows' => $split_row, 'rows_lang' => $split_row_lang));
     }
     /// POST Method . Save the submit form
     $data = Request::all();
     $myfile = fopen($lang_folder . '/' . $file, "w");
     // begin of file
     $txt = "<?php return [\n";
     fwrite($myfile, $txt);
     foreach ($data['tranfield'] as $key => $value) {
         if ($value != null || $value != '') {
             $txt2 = "'" . trim($data['key'][$key]) . "' => '" . $value . "',\n";
             fwrite($myfile, $txt2);
         } else {
             $txt2 = "'' => '" . $value . "',\n";
             fwrite($myfile, $txt2);
         }
     }
     /// end of file
     $txt = "\n];";
     fwrite($myfile, $txt);
     fclose($myfile);
     return redirect('admin/languages/translate/' . $code . '/' . $file)->with('ok', 'Save successful');
 }
 /**
  * Change language
  * @param  $id
  * @return Response view
  */
 public function change($id)
 {
     $language = Language::find($id);
     Language::where('is_default', '=', 1)->update(['is_default' => 0]);
     $language->is_default = 1;
     $language->save();
     return redirect()->route('languages.index');
 }
 /**
  * Function create construct
  */
 public function __construct()
 {
     $language = Language::where('is_default', '=', 1)->first();
     if ($language == null) {
         \App::setLocale('en');
     } else {
         \App::setLocale($language->code);
     }
     $this->getFeatureGroup();
     $d = $this->sidebar();
     $this->getNotification();
     view()->share('format_date', \App\Configure::where('name', '=', 'format_date')->first()->value);
 }
示例#4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // set locale for all request to display data
     if (!Session::has('locale')) {
         $language = Language::where('is_default', 1)->first();
         if (is_null($language)) {
             $language = Language::first();
         }
         Session::put('locale', $language->code);
     }
     app()->setLocale(Session::get('locale'));
     return $next($request);
 }
 public function getEdit($languageId)
 {
     if (!ACL::hasPermission('languages', 'edit')) {
         return redirect(route('languages'))->withErrors(['You don\'t have permission for edit the language.']);
     }
     $imageDetails = ['folder' => $this->folder, 'flagWidth' => $this->flagWidth, 'flagHeight' => $this->flagHeight];
     $languageLevelsConsult = LanguageLevels::orderBy('languageLevelsId', 'ASC')->get();
     foreach ($languageLevelsConsult as $languageLevel) {
         $languageLevels[$languageLevel['languageLevelsId']] = $languageLevel['languageLevelsName'];
     }
     $language = Language::where('languageId', '=', $languageId)->first();
     return view('admin.language.edit')->with(compact('languageLevels', 'language', 'imageDetails'));
 }
示例#6
0
 public function names(Request $request)
 {
     $language = $request->input('language');
     $searchName = $request->input('search_name');
     if (!$language) {
         $language = $this->defaultLanguage;
     }
     $language = Language::where('iso_name', $language)->first();
     $query = Poem::query();
     if ($searchName) {
         $query = $query->where('name', 'like', '%' . $searchName . '%');
     }
     return $query->where('language_id', $language->id)->paginate(5, ['id', 'name']);
 }
 /**
  * Update configure system
  * 
  * @param  Request $request
  * @return Response
  */
 public function update(Request $request)
 {
     $name = $request->get('name');
     $value = $request->get('value');
     $lan = 0;
     foreach ($name as $key) {
         Configure::where('name', '=', $key)->update(['value' => $value[$lan]]);
         if ($key == "default_language") {
             Language::where('is_default', '=', 1)->update(['is_default' => 0]);
             $language = Language::where('code', '=', $value[$lan])->update(['is_default' => 1]);
         }
         $lan++;
     }
     return redirect()->route('configures.index');
 }
示例#8
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($type, VideosRequest $request)
 {
     $videos = Product::join('videos as v', 'v.product_id', '=', 'id');
     switch ($type) {
         case "movies":
             $videos = $videos->where('type', 'MOVIE');
             $title = 'Movies';
             $heading = 'Movies';
             break;
         case "series":
             $videos = $videos->where('type', 'SERIES');
             $title = 'Series';
             $heading = 'Series';
             break;
         case "anime":
             $videos = $videos->where('type', 'ANIME');
             $title = 'Anime';
             $heading = 'Anime';
             break;
         case "documentries":
             $videos = $videos->where('type', 'VIDEO');
             $title = 'Documentries';
             $heading = 'Documentries';
             break;
         default:
             return redirect()->back();
     }
     // language
     if (!empty($request->language)) {
         $videos = $videos->where('v.language_id', Language::where('name', $request->language)->first()->id);
         $heading = $request->language . ' ' . $heading;
     }
     // query
     if (!empty($request->q)) {
         $videos = $videos->where('name', 'LIKE', '%' . $request->q . '%');
     }
     // sort
     if (!empty($request->sort)) {
         $videos = $videos->orderBy($request->sort, $request->order);
     } else {
         $videos = $videos->orderBy('v.release_date', 'desc');
     }
     // flash input
     $request->flash();
     return view('videos.index')->with('title', $title)->with('heading', $heading)->with('videos', $videos->paginate(env('PAGINATE')))->with('type', $type);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->locale == "en") {
         $test = explode("/", $request->path());
         $test[0] = "gb";
         $test = implode("/", $test);
         return redirect(url($test));
     }
     if (!array_key_exists($request->locale, config("settings.languages")) && $request->cookie("locale") === NULL) {
         $test = explode("/", $request->path());
         $test[0] = config("app.fallback_locale");
         $test = implode("/", $test);
         return redirect(url($test));
     } elseif (!array_key_exists($request->locale, config("settings.languages")) && $request->cookie("locale") !== NULL) {
         $test = explode("/", $request->path());
         $test[0] = $request->cookie("locale");
         $test = implode("/", $test);
         return redirect(url($test));
     }
     if ($request->locale !== null) {
         $cookie = cookie()->forever('locale', $request->locale);
     } elseif ($request->cookie("locale") != NULL) {
         if (!array_key_exists($request->locale, config("settings.languages")) && $request->locale === NULL) {
             $test = explode("/", $request->path());
             $test[0] = $request->cookie("locale");
             $test = implode("/", $test);
             return redirect(url($test));
         }
         $cookie = cookie()->forever("locale", $request->locale);
     } else {
         $cookie = cookie()->forever('locale', config("app.fallback_locale"));
     }
     $language = Language::where("lang", "=", $cookie->getValue())->first();
     $_POST["language_id"] = $language->id;
     app()->setLocale($cookie->getValue());
     /** @var Response $response */
     $response = $next($request);
     return $response->withCookie($cookie);
 }
示例#10
0
 public static function boot()
 {
     // NOTE saving   -> creating -> created   -> saved
     // NOTE saving   -> updating -> updated   -> saved
     // NOTE deleting -> deleted  -> restoring -> restored
     parent::boot();
     // Validate the model
     static::saved(function ($language) {
         // Only one Language can be the default
         if ($language->is_default) {
             Language::where('id', '<>', $language->id)->update(['is_default' => 0]);
         }
         // Purge cache
         Cache::forget('allLanguagesOrderedByPriority');
     });
     static::deleted(function ($language) {
         // Purge cache
         Cache::forget('allLanguagesOrderedByPriority');
     });
     static::restored(function ($language) {
         // Purge cache
         Cache::forget('allLanguagesOrderedByPriority');
     });
 }
示例#11
0
 /**
  * Reorder items
  *
  * @param items list
  * @return items from @param
  */
 public function getReorder(ReorderRequest $request)
 {
     $list = $request->list;
     $items = explode(",", $list);
     $order = 1;
     foreach ($items as $value) {
         if ($value != '') {
             Language::where('id', '=', $value)->update(array('position' => $order));
             $order++;
         }
     }
     return $list;
 }
示例#12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $slider = Slider::findOrFail($id);
     return View('admin.sliders.translate_slider')->with(['slider' => $slider, 'languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get()]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(UserRequest $request, User $user)
 {
     $role = UserRole::where('slug', '=', $request['role'])->first();
     $user->role = $role->id;
     $title = Title::where('slug', '=', $request['title'])->first();
     $user->title = $title->id;
     $language = Language::where('slug', '=', $request['language'])->first();
     $user->language = $language->id;
     $user->name = $request['name'];
     $user->surname = $request['surname'];
     $user->cellphone = $request['cellphone'];
     $user->alt_cellphone = $request['alt_cellphone'];
     $user->email = $request['email'];
     $user->alt_email = $request['alt_email'];
     $province = Province::where('slug', '=', $request['province'])->first();
     $user->province = $province->id;
     $district = District::where('slug', '=', $request['district'])->first();
     $user->district = $district->id;
     $municipality = Municipality::where('slug', '=', $request['municipality'])->first();
     $user->municipality = $municipality->id;
     $ward = Ward::where('slug', '=', $request['ward'])->first();
     $user->ward = $ward->id;
     $department = Department::where('slug', '=', $request['department'])->first();
     $user->department = $department->id;
     $position = Position::where('slug', '=', $request['position'])->first();
     $user->position = $position->id;
     $password = rand(1000, 99999);
     $user->password = \Hash::make($password);
     $user->api_key = uniqid();
     $user->created_by = \Auth::user()->id;
     $user->save();
     \Session::flash('success', $request['name'] . ' ' . $request['surname'] . ' user has been added successfully!');
     $data = array('name' => $user->name, 'username' => $user->email, 'password' => $password);
     \Mail::send('emails.registrationConfirmation', $data, function ($message) use($user) {
         $message->from('*****@*****.**', 'Siyaleader');
         $message->to($user->email)->subject("Siyaleader Notification - User Registration Confirmation: " . $user->name);
     });
     return redirect('list-users');
 }
示例#14
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $menu = Menu::findOrFail($id);
     return View('admin.menus.translate_menu')->with(['languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get(), 'menu' => $menu]);
 }
示例#15
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $content = Content::findOrFail($id);
     return View('admin.contents.translate_content')->with(['languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get(), 'content' => $content]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id != 0) {
         $resumdel1 = PersonalInformation::where('id', $id)->delete();
         $resumdel2 = EducationalInformation::where('pid', $id)->delete();
         $resumdel3 = WorkInformation::where('pid', $id)->delete();
         $resumdel4 = Language::where('pid', $id)->delete();
         $resumdel5 = SkillsInformation::where('pid', $id)->delete();
         $resumdel = AdditionalInformation::where('pid', $id)->delete();
         $resumdel = UploadInformation::where('pid', $id)->delete();
         $resumdel = PrivacyInformation::where('pid', $id)->delete();
     } else {
         $deleteChecked = Input::get('resume');
         if ($deleteChecked) {
             foreach ($deleteChecked as $delete) {
                 $resumdel1 = PersonalInformation::where('id', $delete)->delete();
                 $resumdel2 = EducationalInformation::where('pid', $delete)->delete();
                 $resumdel3 = WorkInformation::where('pid', $delete)->delete();
                 $resumdel4 = Language::where('pid', $delete)->delete();
                 $resumdel5 = SkillsInformation::where('pid', $delete)->delete();
                 $resumdel = AdditionalInformation::where('pid', $delete)->delete();
                 $resumdel = UploadInformation::where('pid', $delete)->delete();
                 $resumdel = PrivacyInformation::where('pid', $delete)->delete();
             }
             Session::flash('message', 'Successfully deleted');
             $history = new History();
             $history->action_id = 0;
             $history->action = 'Resume deleted';
             $history->user = Auth::user()->name;
             $history->remark = 'Number of Resume deleted=' . count($deleteChecked);
             $history->save();
         } else {
             Session::flash('nrmessage', 'Resume are not Selected');
         }
     }
     return Redirect::to('resume');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id != 0) {
         $resumdel1 = PersonalInformation::where('id', $id)->delete();
         $resumdel2 = EducationalInformation::where('pid', $id)->delete();
         $resumdel3 = WorkInformation::where('pid', $id)->delete();
         $resumdel4 = Language::where('pid', $id)->delete();
         $resumdel5 = SkillsInformation::where('pid', $id)->delete();
         $resumdel = AdditionalInformation::where('pid', $id)->delete();
         $resumdel = UploadInformation::where('pid', $id)->delete();
         $resumdel = PrivacyInformation::where('pid', $id)->delete();
     } else {
         $deleteChecked = Input::get('resume');
         if ($deleteChecked) {
             foreach ($deleteChecked as $delete) {
                 $resumdel1 = PersonalInformation::where('id', $delete)->delete();
                 $resumdel2 = EducationalInformation::where('pid', $delete)->delete();
                 $resumdel3 = WorkInformation::where('pid', $delete)->delete();
                 $resumdel4 = Language::where('pid', $delete)->delete();
                 $resumdel5 = SkillsInformation::where('pid', $delete)->delete();
                 $resumdel = AdditionalInformation::where('pid', $delete)->delete();
                 $resumdel = UploadInformation::where('pid', $delete)->delete();
                 $resumdel = PrivacyInformation::where('pid', $delete)->delete();
             }
         }
     }
     Session::flash('message', 'Successfully deleted');
     return Redirect::to('resume');
 }
示例#18
0
 public function getDefaultLanguage()
 {
     $language = Language::where('is_default', '=', '1')->first();
     return $language->code;
 }
 public function resume_preview($id)
 {
     $personal = PersonalInformation::where('id', $id)->first();
     $phd1 = DB::table('educationinformation')->where('pid', $id)->get();
     $experience = WorkInformation::where('pid', $personal->id)->first();
     $skills = SkillsInformation::where('pid', $personal->id)->get();
     $additional = AdditionalInformation::where('pid', $personal->id)->first();
     $language = Language::where('pid', $personal->id)->get();
     $upload = UploadInformation::where('pid', $personal->id)->first();
     $privacy = PrivacyInformation::where('pid', $personal->id)->first();
     return view('resume')->with('personal', $personal)->with('phd1', $phd1)->with('experience', $experience)->with('skills', $skills)->with('additional', $additional)->with('language', $language)->with('upload', $upload);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function captureCaseUpdate(CaseRequest $request)
 {
     $houseHolderId = $request['hseHolderId'];
     $userRole = UserRole::where('name', '=', 'House Holder')->first();
     if ($houseHolderId < 1) {
         $user = new User();
         $user->role = $userRole->id;
         $user->name = $request['name'];
         $user->surname = $request['surname'];
         $user->cellphone = $request['cellphone'];
         $user->id_number = $request['id_number'];
         $user->position = $request['position'];
         $user->title = $request['title'];
         $user->house_number = $request['house_number'];
         $user->email = $request['cellphone'] . "@siyaleader.net";
         $user->created_by = \Auth::user()->id;
         $language = Language::where('slug', '=', $request['language'])->first();
         $user->language = $language->id;
         $province = Province::where('slug', '=', $request['province'])->first();
         $user->province = $province->id;
         $district = District::where('slug', '=', $request['district'])->first();
         $user->district = $district->id;
         $municipality = Municipality::where('slug', '=', $request['municipality'])->first();
         $user->municipality = $municipality->id;
         $ward = Ward::where('slug', '=', $request['ward'])->first();
         $user->ward = $ward->id;
         $user->save();
     }
     $casePriority = CasePriority::where('slug', '=', $request['priority'])->first();
     $case = CaseReport::find($request['caseID']);
     $case->description = $request['description'];
     $case->priority = $casePriority->id;
     $case->updated_by = \Auth::user()->id;
     $case->updated_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString();
     $case->save();
     return 'ok';
 }
示例#21
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $category = Category::findOrFail($id);
     return View('admin.categories.translate_category')->with(['languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get(), 'category' => $category]);
 }
示例#22
0
 /**
  * Change application language.
  *
  * @param ChangeLanguageRequest $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function changeLanguage(ChangeLanguageRequest $request)
 {
     $response = new AjaxResponse();
     $language = Language::where('key', $request->get('language'))->first();
     Auth::user()->settings()->update(['language_id' => $language->id]);
     $response->setSuccessMessage(trans('settings.language_changed'));
     $response->addExtraFields(['language' => $language->language]);
     return response($response->get());
 }