Esempio n. 1
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. 2
0
 public function __construct($data)
 {
     $this->data = $data;
     $this->suitableStars = \App\Star::where('star', $this->data['rare_star'])->get();
     if ($this->suitableStars) {
         $this->search();
     }
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     User::saved(function ($user) {
         \Session::put('newUserId', $user->id);
     });
     Star::creating(function ($star) {
         $star->user_id = \Session::get('newUserId');
     });
 }
Esempio n. 4
0
 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 destroy(Request $request, $article_id)
 {
     $article = Article::findOrFail($article_id);
     $star = Star::filterBy(['article_id' => $article_id, 'user_id' => auth()->user()->id]);
     $star->delete();
     $flash = ['flash_message' => 'You unstarred an article'];
     if ($request->ajax()) {
         return response()->json($flash + ['html' => view('articles._star', compact('article'))->render()]);
     } else {
         return redirect()->back()->with($flash);
     }
 }
Esempio n. 6
0
 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();
     }
 }
Esempio n. 7
0
 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;
     }
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(RegistrationLogics $reg)
 {
     $profileData = [];
     $profileData['city'] = $this->data['city'];
     $profileData['state'] = isset($this->data['state']['name']) ? $this->data['state']['name'] : $this->data['state'];
     $profileData['address'] = isset($this->data['address']) ? $this->data['address'] : "";
     $profileData['roles'] = isset($this->data['role']) ? serialize($this->data['role']) : serialize($this->data['roles']);
     $profileData['bio'] = $this->data['bio'];
     $profileData['image'] = isset($this->data['profile_pic']) ? $this->data['profile_pic'] : $this->data['logo_image'];
     $user = [];
     $user['name'] = $this->data['username'];
     $user['email'] = $this->data['email'];
     $user['password'] = \Hash::make($this->data['password']);
     $user['access_token'] = isset($this->data['access_token']) ? $this->data['access_token'] : '';
     switch ($this->type) {
         case 'star':
             $profileData['first_name'] = $this->data['first_name'];
             $profileData['last_name'] = $this->data['last_name'];
             $user['star'] = 1;
             $profileData['sex'] = $this->data['sex']['value'];
             $profileData['DOB'] = strftime("%Y-%m-%d", strtotime($this->data['DOB']));
             $check = $reg->checkEmail($user['email'], 'star');
             if (is_null($check)) {
                 User::create($user)->starProfile()->save(Star::create($profileData));
             } elseif (!$check) {
                 $model = User::where('email', '=', $user['email'])->first();
                 $model->update(['star' => 1]);
                 User::find($model->id)->starProfile()->save(Star::create($profileData));
             }
             break;
         case 'star maker':
             $profileData['company_name'] = $this->data['company_name'];
             $user['star_maker'] = 1;
             $check = $reg->checkEmail($user['email'], 'star maker');
             if (is_null($check)) {
                 User::create($user)->starMakerProfile()->save(StarMaker::create($profileData));
             } elseif (!$check) {
                 $model = User::where('email', '=', $user['email'])->first();
                 $model->update(['star_maker' => 1]);
                 User::find($model->id)->starMakerProfile()->save(StarMaker::create($profileData));
             }
             break;
         default:
             return false;
             break;
     }
 }
Esempio n. 9
0
 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';
 }
Esempio n. 10
0
 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'));
 }
Esempio n. 11
0
 protected function saveStar()
 {
     $array = ['star' => $this->data['star'], 'size' => $this->data['size'], 'class' => $this->data['class'], 'address_id' => $this->data['address'], 'user_id' => $this->user, 'code' => $this->data['code']];
     $star = \App\Star::create($array);
     $this->starId = $star->id;
 }
Esempio n. 12
0
 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;
 }