REFACTORING #1880 @4h30m: another ugly refactoring commit

This commit is contained in:
Michal Kváček
2016-10-25 16:50:04 +02:00
parent 28f67ffe3c
commit cc999dd24e
71 changed files with 827 additions and 608 deletions
+25 -4
View File
@@ -11,11 +11,32 @@
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
use App\CMS\Contracts\Repositories\Content as ContentContract;
use App\Models\Content\Content;
use App\Models\User;
use Carbon\Carbon;
$factory->define(User::class, function (Faker\Generator $faker) {
$email = $faker->email;
return [
'name' => $faker->name,
'email' => $faker->email,
'username' => $email,
'email' => $email,
'name' => $faker->name,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
'role' => 'admin',
];
});
$factory->define(Content::class, function (Faker\Generator $faker) {
return [
'title' => $faker->sentence(5),
'userId' => 1,
'url' => $faker->slug(5),
'pageContent' => $faker->text(1500),
'metaDescription' => $faker->text,
'moduleHandler' => config('staticpages.handler'),
'language' => env('LOCALES'),
'publishedFrom' => Carbon::now(),
'status' => ContentContract::STATUS_PUBLIC
];
});
@@ -26,7 +26,7 @@ class AddUniqueCodeToWidgets extends Migration
});
// migrate data
$widgets = \App\Models\Widget::all();
$widgets = \App\Models\Widgets\Widget::all();
foreach ($widgets as $widget) {
$widget->settings = json_decode($widget->settings);
if (isset($widget->settings->containerClass)) {
@@ -0,0 +1,67 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RenameColumnInContents extends Migration
{
protected $columns;
public function __construct()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$this->columns = [
'user_id',
'parent_id',
'category_id',
'language',
'module_handler',
'published_from',
'published_to',
'title_photo',
'template',
'is_homepage',
'title',
'url',
'meta_keywords',
'meta_description',
'content',
'module_settings',
'status'
];
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contents', function (Blueprint $table) {
foreach ($this->columns as $column) {
$table->renameColumn($column, camel_case($column));
}
$table->renameColumn('content', 'pageContent');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contents', function (Blueprint $table) {
foreach ($this->columns as $column) {
$table->renameColumn(camel_case($column), $column);
}
$table->renameColumn('pageContent', 'content');
});
}
}