示例#1
0
 protected function makePlanetExtras(planetExtraInfo $extra)
 {
     $array = [];
     $atmosphere = [];
     $composition = [];
     $commonNames = \App\Myclasses\Arrays::commonExtraNames();
     $volcanism = \App\Myclasses\Arrays::volcanism();
     $atmType = \App\Myclasses\Arrays::atmosphereType();
     foreach ($extra->common as $key => $value) {
         if ($key == 'volcanism') {
             $value = $volcanism[$value];
         }
         if ($key == 'atm_type') {
             $value = $atmType[$value];
         }
         $newKey = $commonNames[$key];
         $array[$newKey] = $value;
     }
     $compName = \App\Myclasses\Arrays::planetComposition();
     foreach ($extra->composition as $key => $value) {
         $newKey = $compName[$key];
         $composition[$newKey] = $value . ' %';
     }
     $array['composition'] = $composition;
     $atmNames = \App\Myclasses\Arrays::atmosphereComposition();
     foreach ($extra->atmosphere as $key => $value) {
         if ($value == 0) {
             continue;
         }
         $newKey = $atmNames[$key];
         $atmosphere[$newKey] = $value . ' %';
     }
     $array['atmosphereC'] = $atmosphere;
     $orbitNames = \App\Myclasses\Arrays::orbitExtraNames();
     foreach ($extra->orbit as $key => $value) {
         $newKey = $orbitNames[$key];
         $array[$newKey] = $value;
     }
     return $array;
 }
 public function unitePost(Request $request)
 {
     $data = $request->except('_token');
     $planets = \App\Planet::where('planet', $data['planet'])->wherePlandataPrice()->get();
     $array = [];
     $name = '';
     $axis = '';
     $axisNames = [];
     foreach ($planets as $planet) {
         $param = '';
         switch ($data['type']) {
             case 'g':
                 $param = \App\Myclasses\Counter::gravity($planet->mass, $planet->radius);
                 $name = 'Цена от гравитации';
                 $axis = 'G';
                 break;
             case 's':
                 $param = $planet->radius;
                 $name = 'Цена от радиуса';
                 $axis = 'радиус км';
                 break;
             case 't':
                 $param = $planet->temperature;
                 $name = 'Цена от температуры';
                 $axis = 'температура K';
                 break;
             case 'm':
                 $param = $planet->mass;
                 $name = 'Цена от массы';
                 $axis = 'Массы Земли';
                 break;
             case 'p':
                 $param = $planet->pressure;
                 $name = 'Цена от давления';
                 $axis = 'Атмосферы';
                 break;
             case 'a':
                 $param = $planet->atm_type;
                 $name = 'Цена от типа атмосферы';
                 $axis = 'Тип атмосферы';
                 $axisNames = \App\Myclasses\Arrays::atmosphereType();
                 break;
             case 'sg':
                 $param = $planet->{$data}['gas'];
                 $name = 'Цена от состава атмосферы';
                 $axis = 'Концентрация %';
                 break;
             case 'so':
                 $param = $planet->{$data}['orbit'];
                 $name = 'Цена от параметров орбиты';
                 $axis = 'Значение';
                 break;
             case 'v':
                 $param = $planet->volcanism;
                 $name = 'Цена от вулканизма';
                 $axis = 'Тип вулканизма';
                 $axisNames = \App\Myclasses\Arrays::volcanism();
                 break;
         }
         $array[] = ['param' => $param, 'price' => $planet->price];
     }
     return view('moderation.graph', compact('array', 'name', 'axis', 'axisNames'));
 }