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(); } }
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