Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/MigratePrices.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
class MigratePrices extends Command | class MigratePrices extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
Show All 14 Lines | class MigratePrices extends Command | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$this->updateSKUs(); | $this->updateSKUs(); | ||||
$this->updateEntitlements(); | $this->updateEntitlements(); | ||||
} | } | ||||
private function updateSKUs() | private function updateSKUs() | ||||
{ | { | ||||
$bar = \App\Utils::createProgressBar($this->output, 8, "Updating SKUs"); | $bar = $this->createProgressBar(8, "Updating SKUs"); | ||||
// 1. Set the list price for the SKU 'mailbox' to 500. | // 1. Set the list price for the SKU 'mailbox' to 500. | ||||
$bar->advance(); | $bar->advance(); | ||||
$mailbox_sku = \App\Sku::where('title', 'mailbox')->first(); | $mailbox_sku = \App\Sku::where('title', 'mailbox')->first(); | ||||
$mailbox_sku->cost = 500; | $mailbox_sku->cost = 500; | ||||
$mailbox_sku->save(); | $mailbox_sku->save(); | ||||
// 2. Set the list price for the SKU 'groupware' to 490. | // 2. Set the list price for the SKU 'groupware' to 490. | ||||
Show All 38 Lines | private function updateSKUs() | ||||
$this->info("DONE"); | $this->info("DONE"); | ||||
} | } | ||||
private function updateEntitlements() | private function updateEntitlements() | ||||
{ | { | ||||
$users = \App\User::all(); | $users = \App\User::all(); | ||||
$bar = \App\Utils::createProgressBar($this->output, count($users), "Updating entitlements"); | $bar = $this->createProgressBar(count($users), "Updating entitlements"); | ||||
$groupware_sku = \App\Sku::where('title', 'groupware')->first(); | $groupware_sku = \App\Sku::where('title', 'groupware')->first(); | ||||
$activesync_sku = \App\Sku::where('title', 'activesync')->first(); | $activesync_sku = \App\Sku::where('title', 'activesync')->first(); | ||||
$storage_sku = \App\Sku::where('title', 'storage')->first(); | $storage_sku = \App\Sku::where('title', 'storage')->first(); | ||||
$mailbox_sku = \App\Sku::where('title', 'mailbox')->first(); | $mailbox_sku = \App\Sku::where('title', 'mailbox')->first(); | ||||
foreach ($users as $user) { | foreach ($users as $user) { | ||||
$bar->advance(); | $bar->advance(); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |