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 __construct($id) { //construct new StarInfo dew to the database id $star = \App\Star::find($id); $this->star[$id] = new starInfo($star); //construct planets array with new PlanetInfo objects foreach ($star->planets()->get() as $planet) { $this->planets[$planet->id] = new planetInfo($planet); } }
public function __construct(array $data) { parent::__construct(); $this->data = $data; $this->star = \App\Star::find($data['star_id']); try { $this->defineAddress(); $this->checkPresence(); $this->savePoints(); } catch (\PDOException $e) { $this->rollback(); } }
public function __construct(array $data) { parent::__construct($data); $this->address = \App\Address::find($data['address']); switch ($data['object']) { case 'star': $this->centerObject = \App\Star::find($data['objectId']); break; case 'multi': $this->centerObject = \App\Baricenter::find($data['objectId']); break; } }
public function giveStarData(Request $request) { $type = $request->input('type'); $starId = $request->input('id'); if ($type == 'star') { $star = \App\Star::find($starId); $sData = $star->starData()->first(); if ($sData) { return view($this->localeDir . 'templates.addStarData', compact('starId', 'sData')); } return view($this->localeDir . 'templates.addStarData', compact('starId')); } return 'its not a star'; }
public function starpos(Request $request) { $data = $request->except('_token'); foreach ($data as $key => $value) { $star = \App\Star::find($key); $star->code = $value; $star->save(); } return redirect(route('multi')); }
public static function getFromDb($id) { $data = \App\Star::find($id); $newStar = new self($data->code, $data->star, $data->size, $data->class, $data->user); return $newStar; }