public function updateFixed(Request $request)
 {
     foreach ($request->all() as $key => $val) {
         if (strpos($key, 'Price') !== FALSE) {
             $price = SiteConfig::firstOrCreate(['parameter' => $key]);
             $price->data = $val;
             $price->save();
             unset($price);
         }
     }
     return redirect()->back();
 }
 public function updateCloud()
 {
     $recordsServer = SiteConfig::whereParameter('recordsUrl')->first();
     $client = new Client(['base_uri' => $recordsServer->data]);
     $data = $client->get("api/getPricing");
     $pricing = json_decode($data->getBody());
     $data = $client->get("api/getResourceLimits");
     $resourceLimits = json_decode($data->getBody());
     foreach ($resourceLimits as $resource => $limit) {
         $dbEntry = SiteConfig::firstOrCreate(['parameter' => 'RL' . $resource]);
         $dbEntry->data = $limit;
         $dbEntry->save();
     }
     flash()->success('Cloud settings successfully updated.');
     return redirect()->route('admin.settings.index');
 }
Пример #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Setup HTTP request for the records
     $url = SiteConfig::whereParameter('recordsUrl')->first()->data;
     $client = new Client(['base_uri' => $url]);
     $data = $client->get("api/getPricing");
     $priceData = json_decode($data->getBody());
     $priceMethod = SiteConfig::firstOrCreate(['parameter' => 'priceMethod']);
     $priceMethod->data = $priceData->priceMethod;
     $priceMethod->save();
     DB::statement('TRUNCATE element_costs');
     foreach ($priceData->prices as $price) {
         if ($priceData->priceMethod == 'fixedRatio') {
             $frPrice = SiteConfig::firstOrCreate(['parameter' => $price->parameter]);
             $frPrice->data = $price->data;
             $frPrice->save();
         } else {
             if ($priceData->priceMethod == 'elementPrice') {
                 ElementCost::create(['element' => $price->element, 'quantity' => $price->quantity, 'quantity_type' => $price->quantity_type, 'price' => $price->price]);
             }
         }
     }
 }
 public function syncACS()
 {
     $acs = app('cloudstack');
     if (is_array($acs)) {
         return -1;
     }
     $offerings = $acs->listDiskOfferings();
     $tags = [];
     foreach ($offerings as $offering) {
         // Extract a list of tags
         if (!isset($offering->tags)) {
             continue;
         }
         if (!in_array($offering->tags, $tags)) {
             $tags[] = $offering->tags;
         }
     }
     foreach ($tags as $tag) {
         // Create a config price and a storage tag if they don't exist.
         StorageType::firstOrCreate(['tag' => $tag]);
         SiteConfig::firstOrCreate(['parameter' => $tag . 'Price']);
     }
     return 1;
 }