/** * Execute the console command. * * @return mixed */ public function handle() { foreach (User::all() as $user) { if (!$user->rsaKey) { throw new \RuntimeException('user ' . $user->email . ' has no RSA key. Create it using key:generate:users'); } } if (!$this->filesystem->exists(config('app.backup_key'))) { $this->warn('Backup key does not exist. We recommend that you create one using key:generate:master'); } $entries = Entry::all(); foreach ($entries as $entry) { $list = $this->accessDecider->getUserListForEntry($entry); if ($list->count() == 0) { throw new \RuntimeException('Entry #' . $entry->id . ' has no access. Share it.'); } } foreach ($entries as $entry) { if ($entry->password != '') { continue; } echo $entry->id . '... '; $this->entryCrypt->encrypt($entry->password, $entry); echo ' encrypted!' . "\n"; } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('user', function ($table) { $table->string('type', 20); }); $users = User::all(); foreach ($users as $user) { if (isset($user->group)) { $user->type = $user->group == 'admin' ? 'admin' : 'member'; $user->save(); } } Schema::table('user', function ($table) { $table->dropColumn('group'); }); Schema::table('user', function ($table) { $table->renameColumn('type', 'group'); }); }
public function index() { return User::all(); }