diff --git a/app/Console/Commands/AddLanguage.php b/app/Console/Commands/AddLanguage.php index f4eb3308..b24ce5be 100644 --- a/app/Console/Commands/AddLanguage.php +++ b/app/Console/Commands/AddLanguage.php @@ -12,7 +12,7 @@ class AddLanguage extends Command * * @var string */ - protected $signature = 'language:add {code} {translation}'; + protected $signature = 'language:add {code} {translation} {native} {script?}'; /** * The console command description. * @@ -39,6 +39,8 @@ class AddLanguage extends Command { $code = $this->argument('code'); $translation = $this->argument('translation'); + $native = $this->argument('native'); + $script = $this->argument('script'); // check if language does not exist $exist = Language::find($code); @@ -48,7 +50,12 @@ class AddLanguage extends Command return; } - Language::create(['code' => $code, 'name' => $translation]); + Language::create([ + 'code' => $code, + 'name' => $translation, + 'native' => $native, + 'script' => $script ? $script : 'Latn' + ]); $this->line('Successfully installed.'); } diff --git a/app/Models/Language.php b/app/Models/Language.php index 3aca77ac..2cef168a 100644 --- a/app/Models/Language.php +++ b/app/Models/Language.php @@ -8,11 +8,11 @@ class Language extends Model { public $timestamps = false; public $primaryKey = 'code'; - protected $fillable = [ 'code', - 'name' + 'name', + 'script', + 'native' ]; - protected $guarded = []; } \ No newline at end of file diff --git a/database/migrations/2016_07_21_221547_AddFieldsIntoLanguages.php b/database/migrations/2016_07_21_221547_AddFieldsIntoLanguages.php new file mode 100644 index 00000000..434c5c45 --- /dev/null +++ b/database/migrations/2016_07_21_221547_AddFieldsIntoLanguages.php @@ -0,0 +1,37 @@ +string('script', 16) + ->default('Latn') + ->comment('ISO code for locale script (Latn, Arab, ...)'); + $table->string('native') + ->comment('Native name for language'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('languages', function (Blueprint $table) { + $table->dropColumn('script'); + $table->dropColumn('native'); + }); + } +}