/** * Run the migrations. * * @return void */ public function up() { User::chunk(500, function ($users) { foreach ($users as $user) { if (strlen($user->barcode_id) > 10) { $user->barcode_id = substr($user->barcode_id, 0, 9); $user->forceSave(); } } }); }
/** * Updates the metadata from wordpress on existing users */ public function updateExistingUsers() { OctoberUser::chunk(500, function ($users) { foreach ($users as $user) { $id = $this->db->table('wp_users')->select('ID')->where('user_email', $user->email)->first(); if (!$id) { continue; } $this->updateMetadata($user, $id->ID); } }); }
protected function synchronizeUser() { $alwaysUpdate = $this->option('force-update'); $this->progressbar = $this->getHelperSet()->get('progress'); $this->progressbar->start($this->output, User::count()); User::chunk(500, function ($users) use($alwaysUpdate) { foreach ($users as $user) { $this->progressbar->advance(); $email = $user->email; MailChimpIntegration::syncMemberToMailChimp($email, $user, false); } }); ${$this}->progressbar->finish(); }
/** * Read and process incomming data from listenable channels * @return void */ public function fire() { // Long run queries fill memory pretty quickly due to a default // behavior of Laravel where all queries are log in memory. Disabling // this log fix the issue. See http://laravel.com/docs/4.2/database#query-logging DB::connection()->disableQueryLog(); User::chunk(200, function ($users) { foreach ($users as $user) { $this->increaseCounter('total_users'); $data = $this->normalize($user); foreach ($data as $attr => $value) { $user->{$attr} = $value; } $user->forceSave(); } }); var_dump($this->counters); var_dump($this->writeReport()); }