/** @test */ public function it_stores_country() { $dbCountryRepository = new DbCountryRepository(); $countryModel = new Country(); $countryFillableKeys = $countryModel->getFillable(); $expectedCountryData = array_only(factory(Country::class, 'relationless')->make()->toArray(), $countryFillableKeys); $this->dontSeeInDatabase('countries', $expectedCountryData); $country = $dbCountryRepository->store($expectedCountryData); $this->assertNotFalse($country); $this->seeInDatabase('countries', $expectedCountryData); }
/** * Run the database seeds. * * @return void */ public function run() { $dbIndustryRepository = new DbIndustryRepository(); $dbCountryRepository = new DbCountryRepository(); $dbUserRepository = new DbUserRepository(); $healthIndustry = $dbIndustryRepository->findByName('Health'); $countries = $dbCountryRepository->all()->toArray(); $companyRepresentativeUsers = $dbUserRepository->withCompanyRepresentativeRole()->get()->toArray(); $faker = Factory::create(); foreach ($this->popularCompanies as $company) { factory(Company::class, 'relationless')->create(['name' => $company['name'], 'description' => $company['description'], 'industry_id' => $healthIndustry->id, 'country_id' => $faker->randomElement($countries)['id'], 'user_id' => $faker->randomElement($companyRepresentativeUsers)['id'], 'logo_id' => factory(File::class)->create()->id]); } }
/** * Run the database seeds. * * @return void */ public function run() { $dbCountryRepository = new DbCountryRepository(); $dbCountryRepository->store(['name' => 'Greece']); $dbCountryRepository->store(['name' => 'Germany']); }