Наследование: extends Illuminate\Database\Eloquent\Model
Пример #1
1
 public function test_it_can_activate_a_language()
 {
     $LanguageManager = new LanguagesManager(new \DvsLanguage());
     $LanguageManager->modifyActiveFlag($id = 31, $isActive = true);
     // the active flag should be true now...
     assertEquals(true, \DvsLanguage::find(31)->active);
 }
Пример #2
0
 /**
  * Updates the active field of a language
  *
  * @param $id
  * @param $isActive
  * @internal param array $input
  * @return $this
  */
 public function modifyActiveFlag($id, $isActive)
 {
     $language = $this->Language->findOrFail($id);
     $language->active = $isActive === 'true' || $isActive === true || $isActive === 1;
     $language->save();
     return $this;
 }
Пример #3
0
 public function test_it_finds_localized_page()
 {
     // create a translated spanish page of page #1
     $this->createTestPage(['translated_from_page_id' => '1', 'language_id' => '162', 'route_name' => 'dvs-pages-es', 'slug' => '/admin/es/pages']);
     $CurrentLanguage = \DvsLanguage::find(162);
     $this->LanguageDetector->shouldReceive('current')->andReturn($CurrentLanguage);
     $EnglishPage = \DvsPage::find(1);
     $SpanishPage = $this->PagesRepository->findLocalizedPage($EnglishPage);
     assertEquals(99999, $SpanishPage->id);
 }
Пример #4
0
 /**
  * We don't use this, but we could use it later
  * if we wanted to. It would get the locale
  * from the first segment of the url, e.g.
  *
  * 	http://somesite.com/en/cool/page
  *
  * @return string
  */
 public function segment()
 {
     $segment = $this->Framework->Request->segment(1, null);
     $languages = \DvsLanguage::getCodesArray();
     return in_array($segment, $languages) ? $segment : null;
 }