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();
     }
 }
Exemple #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();
     }
 }
 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'));
 }
    <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>
            @foreach($planets as $key=>$value)
                <option value="{{$key}}">{{$value}}</option>
            @endforeach
Exemple #5
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;
 }
Exemple #6
0
 protected function savePlanet()
 {
     $array = ['baricenter_id' => $this->star->id, 'planet' => $this->data['planet'], 'mark' => $this->data['mark'], 'distance' => $this->data['distance'], 'user_id' => $this->user];
     $planet = \App\Bariplanet::create($array);
     $this->planetId = $planet->id;
 }