Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Languages::truncate();
     Languages::create(['name' => 'English']);
     Languages::create(['name' => 'Russian']);
     Languages::create(['name' => 'French']);
 }
 /**
  * Show the form for editing the specified sitelanguages.
  *
  * @param  int  $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $sitelanguages = SiteLanguages::find($id);
     $sites = Sites::site_access()->lists('title', 'id')->prepend('Please select', '');
     $languages = Languages::lists('code', 'id')->prepend('Please select', '');
     return view('admin.sitelanguages.edit', compact('sitelanguages', 'sites', 'languages'));
 }
Beispiel #3
0
 public static function getTranslate($word, $from, $to)
 {
     //Create path to languages models
     $fromModel = "App\\" . ucfirst($from) . '_Word';
     $toModel = "App\\" . ucfirst($to) . '_Word';
     //Create languages models objects
     $sWord = new $fromModel();
     $tWord = new $toModel();
     if (!isset($sWord)) {
         echo 'Not support sourse language';
     } elseif (!isset($tWord)) {
         echo 'Not support target language';
     } else {
         //Get  sourse language id
         $sourseLang = Languages::where('name', $from)->get();
         //Get  target language id
         $targetLang = Languages::where('name', $to)->get();
         //Get sourse word id
         $sWord = $sWord->where('word', $word)->get();
         //Get id's from objects
         $sLangId = $sourseLang[0]['id'];
         $tLangId = $targetLang[0]['id'];
         $sWordId = $sWord[0]['id'];
         //Get result word
         $tWordId = Translations::where('sLangId', $sLangId)->where('tLangId', $tLangId)->where('sWordId', $sWordId)->get();
         if (count($tWordId) === 0) {
             $tWordId = Translations::where('sLangId', $tLangId)->where('tLangId', $sLangId)->where('tWordId', $sWordId)->get();
             $tWordId = $tWordId[0]['sWordId'];
         } else {
             $tWordId = $tWordId[0]['tWordId'];
         }
         $tWord = $tWord->where('id', $tWordId)->get();
         $tWord = $tWord[0]['word'];
         mb_strtolower($word) === $word ? $result = $tWord : ($result = Str::title($tWord));
         $data = array('word' => $word, 'sourse' => $from, 'target' => $to, 'result' => $result);
         return $data;
     }
 }
Beispiel #4
0
 public static function boot()
 {
     parent::boot();
     Languages::observe(new UserActionsObserver());
 }
 /**
  * Mass delete function from index page
  * @param Request $request
  *
  * @return mixed
  */
 public function massDelete(Request $request)
 {
     if ($request->get('toDelete') != 'mass') {
         $toDelete = json_decode($request->get('toDelete'));
         Languages::destroy($toDelete);
     } else {
         Languages::whereNotNull('id')->delete();
     }
     return redirect()->route('admin.languages.index');
 }