Commit 855e36fc authored by Jack Stupple's avatar Jack Stupple

add new languages support

parent e226f53e
......@@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class Language extends Model
{
protected $fillable = ['slug', 'name', 'enabled'];
public function players()
{
return $this->hasMany(Player::class);
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddNewSupportedLanguages extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$now = date('Y-m-d H:i:s');
// remove the old one that was spelled wrong
$de = \App\Language::where('name', 'Deutch')->first();
if ($de) {
$de->delete();
}
$de = \App\Language::firstOrCreate([
'name' => 'Nederlands',
'slug' => 'de'
]);
$de->enabled = $now;
$de->save();
$no = \App\Language::firstOrCreate([
'name' => 'Norsk',
'slug' => 'no'
]);
$no->enabled = $now;
$no->save();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$de = \App\Language::where('slug', 'de')->first();
if ($de) {
$de->enabled = null;
$de->save();
}
$no = \App\Language::where('slug', 'no')->first();
if ($no) {
$no->enabled = null;
$no->save();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment