private function createCountries($countries) { foreach ($countries as $data) { $country = new Country(); $country->id = $data['id']; $country->code = $data['code']; $country->save(); } }
public function test_it_returns_the_translation_with_inner_join() { DB::enableQueryLog(); $this->app->setLocale('el'); /** @var Country $country */ $country = Country::joinTranslation()->first(); $this->assertEquals('Ελλάδα', $country->name); $queries = DB::getQueryLog(); $this->assertEquals(1, count($queries), 'You have with innerjoin more than one query'); }
public function test_whereTranslationLike_filters_by_translation_and_locale() { Country::create(['code' => 'some-code', 'name' => 'Griechenland']); $this->assertSame(2, Country::whereTranslationLike('name', 'Griechen%')->count()); $result = Country::whereTranslationLike('name', '%riechenlan%', 'de')->get(); $this->assertSame(1, $result->count()); $this->assertSame('gr', $result->first()->code); }
public function testRunningMigration() { $country = Country::find(1); $this->assertEquals('gr', $country->code); }
public function test_it_should_hide_attributes_after_to_array() { $country = Country::find(1); $this->assertEquals(true, isset($country->toArray()['name'])); // it is equivalent to set // protected $hidden = ['name']; // in Eloquent $country->setHidden(['name']); $this->assertEquals(false, isset($country->toArray()['name'])); }