Esempio n. 1
0
 public function __construct($data)
 {
     parent::__construct();
     if (isset($data['locked'])) {
         $data['locked'] = 'locked';
     } else {
         $data['locked'] = 'no';
     }
     $this->atmosphere = ['amm' => $data['amm'], 'oxy' => $data['oxy'], 'nit' => $data['nit'], 'arg' => $data['arg'], 'hel' => $data['hel'], 'wat' => $data['wat'], 'hyd' => $data['hyd'], 'sud' => $data['sud'], 'cad' => $data['cad'], 'irn' => $data['irn'], 'met' => $data['met'], 'neo' => $data['neo'], 'sil' => $data['sil']];
     $this->composition = ['ice' => $data['ice'], 'rock' => $data['rock'], 'metal' => $data['metal']];
     $this->orbit = ['orbP' => $data['orbP'], 'mAxis' => $data['mAxis'], 'ecce' => $data['ecce'], 'incl' => $data['incl'], 'peri' => $data['peri'], 'rotP' => $data['rotP'], 'aTilt' => $data['aTilt'], 'locked' => $data['locked']];
     $this->common = ['mass' => $data['mass'], 'radius' => $data['radius'], 'temperature' => $data['temperature'], 'pressure' => $data['pressure'], 'volcanism' => $data['volcanism'], 'atm_type' => $data['atm_type'], 'price' => $data['price']];
     switch ($data['planet_type']) {
         case 'planet':
             $this->planet = \App\Planet::find($data['planet_id']);
             break;
         default:
             $this->planet = \App\Bariplanet::find($data['planet_id']);
             $this->bMark = true;
             break;
     }
     try {
         $this->defineAddress();
         $this->checkPresence();
         $this->savePoints();
     } catch (\PDOException $e) {
         $this->rollback();
     }
 }
Esempio n. 2
0
 public function __construct($object, $data)
 {
     $this->data = $data;
     \DB::beginTransaction();
     try {
         switch ($object) {
             case 'star':
                 $this->toChange = \App\Star::find($data['id']);
                 $this->address = $this->toChange->address;
                 $this->changeStar();
                 $this->finalize();
                 break;
             case 'planet':
                 $this->toChange = \App\Planet::find($data['id']);
                 $this->address = $this->toChange->star->address;
                 $this->changePlanet();
                 $this->finalize();
                 break;
             case 'bari':
                 $this->toChange = \App\Bariplanet::find($data['id']);
                 $this->address = $this->toChange->center->address;
                 $this->changePlanet();
                 $this->finalize();
                 break;
             case 'multi':
                 $this->toChange = \App\Baricenter::find($data['id']);
                 $this->address = $this->toChange->address;
                 $this->changeMulti();
                 $this->finalize();
                 break;
         }
     } catch (\PDOException $e) {
         $this->rollback();
     }
 }
Esempio n. 3
0
 protected function savePlanet()
 {
     $array = ['star_id' => $this->star->id, 'planet' => $this->data['planet'], 'mark' => $this->data['mark'], 'distance' => $this->data['distance'], 'user_id' => $this->user];
     $planet = \App\Planet::create($array);
     $this->planetId = $planet->id;
     if ($this->ignore == 1) {
         $planet->show = 'false';
         $planet->save();
     }
 }
Esempio n. 4
0
 private function search()
 {
     $suitablePlanets = \App\Planet::where('planet', $this->data['planet'])->whereBetween('distance', [$this->data['distance'] * 0.99, $this->data['distance'] * 1.01])->get();
     $suitableStars = [];
     foreach ($suitablePlanets as $one) {
         if ($one->star->star != $this->data['star']) {
             continue;
         }
         if ($one->star->class != $this->data['class']) {
             continue;
         }
         if ($one->star->size != $this->data['size']) {
             continue;
         }
         $suitableStars[] = $one->star;
     }
     foreach ($suitableStars as $oneStar) {
         $this->ids[] = $oneStar->address->id;
     }
 }
Esempio n. 5
0
 public function givePlanetData(Request $request)
 {
     $type = $request->input('type');
     $pId = $request->input('id');
     switch ($type) {
         case 'planet':
             $planet = \App\Planet::find($pId);
             $pData = $planet->planetData()->first();
             break;
         default:
             $planet = \App\Bariplanet::find($pId);
             $pData = $planet->planetData()->first();
     }
     if ($pData) {
         return view($this->localeDir . 'templates.addPlanetData', compact('pId', 'type', 'pData'));
     }
     return view($this->localeDir . 'templates.addPlanetData', compact('pId', 'type'));
 }
Esempio n. 6
0
        <button type="submit" class="btn btn-warning">Change</button>
    </form>
    <h4 class="white">Delete</h4>
    <form method="get" action="{{route('changeObject')}}">
        <input type="hidden" value="{{$data['id']}}" name="id">
        <input type="hidden" value="{{$data['type']}}" name="type">
        <input type="hidden" value="delete" name="action">
        <button type="submit" class="btn btn-danger">Delete</button>
    </form>
@endif

@if($data['type'] == 'planet' || $data['type'] == 'bari')
    <?php 
switch ($data['type']) {
    case 'planet':
        $planetData = \App\Planet::find($data['id']);
        break;
    default:
        $planetData = \App\Bariplanet::find($data['id']);
        break;
}
$planets = \App\Myclasses\Arrays::planetsForCabinet();
?>
    <h5>Provided the data: <span class="white">{{$planetData->user->name}}</span></h5>
    <form class="form-inline" method="get" action="{{route('changeObject')}}">
        <input type="hidden" value="{{$data['id']}}" name="id">
        <input type="hidden" value="{{$data['type']}}" name="type">
        <input type="hidden" value="change" name="action">
        <label for="planetD">Planet</label>
        <select name="planet" id="planetD">
            <option value="{{$planetData->planet}}">{{$planets[$planetData->planet]}}</option>
Esempio n. 7
0
 public static function todayStats()
 {
     $today = \Carbon\Carbon::today();
     $now = \Carbon\Carbon::now();
     $statistics = \App\Statcache::whereBetween('created_at', [$today, $now])->first();
     if (!$statistics) {
         $planets = Planet::all()->count();
         $bPlanets = \App\Bariplanet::all()->count();
         $regions = \App\Region::all()->count();
         $addresses = \App\Address::all()->count();
         $tf = Planet::where('planet', '<', 4)->count();
         $bTf = \App\Bariplanet::where('planet', '<', 4)->count();
         $statistics = \App\Statcache::create(['planets' => $planets + $bPlanets, 'regions' => $regions, 'tf' => $tf + $bTf, 'addresses' => $addresses, 'latest_stars' => 0, 'latest_planets' => 0, 'latest_regions' => 0, 'latest_addresses' => 0]);
     }
     $stat['latest'] = $statistics->latest_stars + $statistics->latest_planets;
     $stat['total'] = $statistics->planets;
     $stat['sys'] = $statistics->addresses;
     $stat['tf'] = $statistics->tf;
     $stat['reg'] = $statistics->regions;
     return $stat;
 }
 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'));
 }
Esempio n. 9
0
 protected function addPlanets($differentPlanets, $oldStarId)
 {
     foreach ($differentPlanets as $id) {
         $planet = \App\Planet::find($id);
         $planet->star_id = $oldStarId;
         $planet->save();
     }
 }
Esempio n. 10
0
 public static function getFromDb($id)
 {
     $data = \App\Planet::find($id);
     $newPlanet = new self($data->planet, $data->distance, $data->mark, $data->user);
     return $newPlanet;
 }