/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('djs', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('realname');
         $table->string('picture');
         $table->timestamps();
     });
     Eloquent::unguard();
     $users = User::all();
     foreach ($users as $user) {
         DJ::create(['id' => $user->id, 'name' => $user->dj_name, 'picture' => $user->picture, 'realname' => $user->name]);
     }
     Schema::table('user', function (Blueprint $table) {
         $table->dropColumn('dj_name');
         $table->dropColumn('picture');
         $table->dropColumn('active');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $users = User::all();
     $roles = Role::all();
     $normalRole = $roles->where('name', 'user')->first();
     $editorRole = $roles->where('name', 'admin')->first();
     $adminRole = $roles->where('name', 'super_admin')->first();
     $users->each(function ($user) use($normalRole, $editorRole, $adminRole) {
         if ($user->role->id != $normalRole->id && $user->role->id != $adminRole->id) {
             $user->role()->associate($editorRole);
             $user->save();
         }
     });
     $editorRole->name = 'editor';
     $editorRole->description = 'Content Editor';
     $editorRole->save();
     $adminRole->name = 'admin';
     $adminRole->description = 'Administrator';
     $adminRole->save();
     $ids = [$normalRole->id, $editorRole->id, $adminRole->id];
     DB::table('user_roles')->whereNotIn('id', $ids)->delete();
 }