adding some seeders
This commit is contained in:
parent
38f62e7df6
commit
3ff3ccb40e
21
src/database/seeders/DatabaseSeeder.php
Normal file
21
src/database/seeders/DatabaseSeeder.php
Normal 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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
75
src/database/seeders/LanguageSeeder.php
Normal file
75
src/database/seeders/LanguageSeeder.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user