コード例 #1
0
 public function run()
 {
     $countries = file_get_contents(__DIR__ . '/countries.json');
     $countries = json_decode($countries);
     foreach ($countries->data as $country) {
         Country::create(['iso_code_2' => $country->iso_code_2, 'iso_code_3' => $country->iso_code_3, 'en' => ['name' => $country->name]]);
     }
 }
コード例 #2
0
 public function testItCanReturnAnIsoCode2BasedArray()
 {
     $repo = $this->getRepo();
     $db = app('db');
     $amount = $db->table('country')->count();
     $samples = Country::with('translations')->take(2)->get();
     $result = $repo->select()->toArray();
     foreach ($samples as $sample) {
         $this->assertArraySubset([$sample->iso_code_2 => $sample->name], $result);
     }
     $this->assertCount($amount, $result);
 }