FEATURE: add fields for languages
This commit is contained in:
@@ -12,7 +12,7 @@ class AddLanguage extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'language:add {code} {translation}';
|
protected $signature = 'language:add {code} {translation} {native} {script?}';
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
@@ -39,6 +39,8 @@ class AddLanguage extends Command
|
|||||||
{
|
{
|
||||||
$code = $this->argument('code');
|
$code = $this->argument('code');
|
||||||
$translation = $this->argument('translation');
|
$translation = $this->argument('translation');
|
||||||
|
$native = $this->argument('native');
|
||||||
|
$script = $this->argument('script');
|
||||||
|
|
||||||
// check if language does not exist
|
// check if language does not exist
|
||||||
$exist = Language::find($code);
|
$exist = Language::find($code);
|
||||||
@@ -48,7 +50,12 @@ class AddLanguage extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Language::create(['code' => $code, 'name' => $translation]);
|
Language::create([
|
||||||
|
'code' => $code,
|
||||||
|
'name' => $translation,
|
||||||
|
'native' => $native,
|
||||||
|
'script' => $script ? $script : 'Latn'
|
||||||
|
]);
|
||||||
|
|
||||||
$this->line('Successfully installed.');
|
$this->line('Successfully installed.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ class Language extends Model
|
|||||||
{
|
{
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
public $primaryKey = 'code';
|
public $primaryKey = 'code';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'code',
|
'code',
|
||||||
'name'
|
'name',
|
||||||
|
'script',
|
||||||
|
'native'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddFieldsIntoLanguages extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('languages', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user