adding some seeders

This commit is contained in:
Brian 2022-05-05 12:26:23 -06:00
parent 38f62e7df6
commit 3ff3ccb40e
Signed by: brian
GPG Key ID: DE1A5390A3B84CD8
2 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call([
LanguageSeeder::class,
]);
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace Database\Seeders;
use App\Models\Language;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class LanguageSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$languages = [
[
'iso_code' => 'en_US',
'locale' => 'en',
'country_code' => 'US',
'title' => 'English',
'title_localized' => 'English',
],
[
'iso_code' => 'de_DE',
'locale' => 'de',
'country_code' => 'DE',
'title' => 'German',
'title_localized' => 'Deutsch',
],
[
'iso_code' => 'fr_FR',
'locale' => 'fr',
'country_code' => 'FR',
'title' => 'French',
'title_localized' => 'Français',
],
[
'iso_code' => 'es_SP',
'locale' => 'es',
'country_code' => 'SP',
'title' => 'Spanish',
'title_localized' => 'Español',
],
[
'iso_code' => 'jp_JP',
'locale' => 'jp',
'country_code' => 'JP',
'title' => 'Japanese',
'title_localized' => '日本',
],
[
'iso_code' => 'zh_TW',
'locale' => 'zh',
'country_code' => 'TW',
'title' => 'Taiwanese',
'title_localized' => '台湾',
],
];
$startTime = Carbon::now();
$offset = 0;
foreach ($languages as $language) {
$datetime = $startTime->copy()->addMinute($offset)->toDateTimeString();
$offset++;
$language['created_at'] = $datetime;
$language['updated_at'] = $datetime;
Language::create($language);
}
}
}