mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
huge Laravel 10 upgrade
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator;
|
||||
use JoeDixon\Translation\Language;
|
||||
|
||||
$factory->define(Language::class, function (Generator $faker) {
|
||||
return [
|
||||
'language' => $faker->word,
|
||||
'name' => $faker->word,
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator;
|
||||
use JoeDixon\Translation\Language;
|
||||
use JoeDixon\Translation\Translation;
|
||||
|
||||
$factory->define(Translation::class, function (Generator $faker) {
|
||||
return [
|
||||
'language_id' => function () {
|
||||
return factory(Language::class)->create()->id;
|
||||
},
|
||||
'group' => $faker->word,
|
||||
'key' => $faker->word,
|
||||
'value' => $faker->sentence,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Translation::class, 'group', function (Generator $faker) {
|
||||
return [
|
||||
'language_id' => function () {
|
||||
return factory(Language::class)->create()->id;
|
||||
},
|
||||
'group' => $faker->word,
|
||||
'key' => $faker->word,
|
||||
'value' => $faker->sentence,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Translation::class, 'single', function (Generator $faker) {
|
||||
return [
|
||||
'language_id' => function () {
|
||||
return factory(Language::class)->create()->id;
|
||||
},
|
||||
'group' => 'single',
|
||||
'key' => $faker->word,
|
||||
'value' => $faker->sentence,
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use JoeDixon\Translation\Language;
|
||||
|
||||
class CreateLanguagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('translation.database.connection'))
|
||||
->create(config('translation.database.languages_table'), function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->nullable();
|
||||
$table->string('language');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$initialLanguages = array_unique([
|
||||
config('app.fallback_locale'),
|
||||
config('app.locale'),
|
||||
]);
|
||||
|
||||
foreach ($initialLanguages as $language) {
|
||||
Language::firstOrCreate([
|
||||
'language' => $language,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('translation.database.connection'))
|
||||
->dropIfExists(config('translation.database.languages_table'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTranslationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('translation.database.connection'))
|
||||
->create(config('translation.database.translations_table'), function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('language_id');
|
||||
$table->foreign('language_id')->references('id')
|
||||
->on(config('translation.database.languages_table'));
|
||||
$table->string('group')->nullable();
|
||||
$table->text('key');
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('translation.database.connection'))
|
||||
->dropIfExists(config('translation.database.translations_table'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user