本文整理汇总了PHP中app\models\Country::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::create方法的具体用法?PHP Country::create怎么用?PHP Country::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Country
的用法示例。
在下文中一共展示了Country::create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('Countries')->delete();
Country::create(['id' => 1, 'country_name' => 'Lithuania']);
Country::create(['id' => 2, 'country_name' => 'Russia']);
Country::create(['id' => 3, 'country_name' => 'Germany']);
}
示例2: run
public function run()
{
DB::table('users')->delete();
$VK = new VK(env('VK_APP_ID'), env('VK_KEY_SECRET'));
$vkCountries = $VK->api('database.getCountries', ['need_all' => 1, 'count' => 1000, 'lang' => 'ru']);
foreach ($vkCountries['response'] as $country) {
Country::create(['id' => $country['cid'], 'title' => $country['title']]);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Start country seeder!');
$countries = $this->getCountryArray();
foreach ($countries as $code => $name) {
Country::create(['name' => $name, 'code' => $code]);
}
$this->command->info('Country table seeded!');
}
示例4: createStartingCountries
private static function createStartingCountries(Field $field)
{
$countries = new Collection();
for ($x = 0; $x < \Config::get('settings.fieldWidth'); $x++) {
for ($y = 0; $y < \Config::get('settings.fieldHeight'); $y++) {
$countries->push(Country::create(['x' => $x, 'y' => $y, 'field_id' => $field->id]));
}
}
return $countries;
}
示例5: update
public function update($id)
{
// save updated
$record = $this->records->find($id);
if (!$record) {
Country::create(Input::all());
return $this->respond($record);
}
$record->fill(Input::all())->save();
return $this->respond($record);
}
示例6: handle
/**
* Execute the job.
*
* @param Country $country
*/
public function handle(Country $country)
{
/**
* Save all Countries
*/
$this->countries->transform(function ($name, $code) use($country) {
return $country->create(compact('name', 'code'));
});
/**
* Announce CountryWasCreated
*/
event(new CountryWasCreated($this->countries->toArray()));
}
示例7: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('country', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->string('code', 2)->primary()->unique();
$table->string('name')->index();
$table->string('local_name')->index();
$table->timestamps();
});
// FIXTURES EU Countries
$data = [];
$file = file_get_contents(base_path() . '/database/fixtures/countries.csv');
$lines = str_getcsv($file, "\n");
foreach ($lines as $line) {
$keys = ['local_name', 'name', 'code'];
$row = array_combine($keys, str_getcsv($line, ';'));
Country::create($row);
}
}
示例8: run
public function run ()
{
DB::table('countries')->delete();
Country::create([
'cname' => '中国',
'ename' => 'China',
'code' => 1,
'active' => 1
]);
}