/** * @param array $data */ private function execute(array $data) { /** * User */ foreach ($data as $user) { $profile = $user['profile']; $events = $user['events']; unset($user['profile'], $user['events']); $user_data = \Flocc\User::create($user); $user_id = $user_data->getId(); /** * User profile */ $profile['user_id'] = $user_id; \Flocc\Profile::create($profile); /** * User events */ foreach ($events as $event) { $scoring = $event['scoring']; unset($event['scoring']); $event['user_id'] = $user_id; $event = \Flocc\Events\Events::create($event); /** * Event activities */ \Flocc\Events\Activities::create(['event_id' => $event->getId(), 'activity_id' => rand(1, 3)]); /** * Event members */ \Flocc\Events\Members::create(['event_id' => $event->getId(), 'user_id' => $user_id, 'status' => 'member']); /** * Add scoring */ $scoring['event_id'] = $event->getId(); \Flocc\Events\Scoring::create([$scoring]); } /** * Mail label */ \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Skrzynka odbiorcza', 'type' => 'inbox']); \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Kosz', 'type' => 'trash']); \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Archiwum', 'type' => 'archive']); } }
/** * Update settings * * @param int $id * * @return \Illuminate\Http\Response */ public function editSettings($id) { /** * @var $profile \Flocc\Profile */ $profile = Profile::findOrFail($id); $partying = Profile\Partying::all(); $alcohol = Profile\Alcohol::all(); $smoking = Profile\Smoking::all(); $imprecation = Profile\Imprecation::all(); $plannings = Profile\Plannings::all(); $plans = Profile\Plans::all(); $vegetarian = Profile\Vegetarian::all(); $flexibility = Profile\Flexibility::all(); $plans_change = Profile\PlansChange::all(); $verbosity = Profile\Verbosity::all(); $vigor = Profile\Vigor::all(); $cool = Profile\Cool::all(); $rules = Profile\Rules::all(); $opinions = Profile\Opinions::all(); $tolerance = Profile\Tolerance::all(); $compromise = Profile\Compromise::all(); $feelings = Profile\Feelings::all(); $emergency = Profile\Emergency::all(); $features_sets = Profile\Features::where(['is_set' => '1'])->get(); $features = Profile\Features::where(['is_set' => '0'])->get(); $free_time = Profile\FreeTime::all(); if (!empty(\Input::get())) { $post = \Input::get(); if (isset($post['partying_id'])) { $profile->setPartyingId($post['partying_id']); } if (isset($post['alcohol_id'])) { $profile->setAlcoholId($post['alcohol_id']); } if (isset($post['smoking_id'])) { $profile->setSmokingId($post['smoking_id']); } if (isset($post['imprecation_id'])) { $profile->setImprecationId($post['imprecation_id']); } if (isset($post['imprecation_id'])) { $profile->setImprecationId($post['imprecation_id']); } if (isset($post['plannings_id'])) { $profile->setPlanningsId($post['plannings_id']); } if (isset($post['plans_id'])) { $profile->setPlansId($post['plans_id']); } if (isset($post['vegetarian_id'])) { $profile->setVegetarianId($post['vegetarian_id']); } if (isset($post['verbosity_id'])) { $profile->setVerbosityId($post['verbosity_id']); } if (isset($post['vigor_id'])) { $profile->setVigorId($post['vigor_id']); } if (isset($post['cool_id'])) { $profile->setCoolId($post['cool_id']); } if (isset($post['rules_id'])) { $profile->setRulesId($post['rules_id']); } if (isset($post['opinions_id'])) { $profile->setOpinionsId($post['opinions_id']); } if (isset($post['tolerance_id'])) { $profile->setToleranceId($post['tolerance_id']); } if (isset($post['compromise_id'])) { $profile->setCompromiseId($post['compromise_id']); } if (isset($post['feelings_id'])) { $profile->setFeelingsId($post['feelings_id']); } if (isset($post['emergency_id'])) { $profile->setEmergencyId($post['emergency_id']); } //->setFlexibilityId($post['flexibility_id']) //->setPlansChangeId($post['plans_change_id']) $profile->save(); $users_features = new Features(); $free_time_user = new FreeTime(); $users_features->clear(\Flocc\Auth::getUserId()); $free_time_user->clear(\Flocc\Auth::getUserId()); if (isset($post['features'])) { foreach ($post['features'] as $feature_id) { $users_features->addNew(\Flocc\Auth::getUserId(), $feature_id); } } if (isset($post['free_time'])) { foreach ($post['free_time'] as $free_time_id) { $free_time_user->addNew(\Flocc\Auth::getUserId(), $free_time_id); } } $message = "Successfully updated"; } return view('profiles.edit.settings', compact('message', 'profile', 'partying', 'alcohol', 'smoking', 'imprecation', 'plannings', 'plans', 'vegetarian', 'flexibility', 'plans_change', 'verbosity', 'vigor', 'cool', 'rules', 'opinions', 'tolerance', 'compromise', 'feelings', 'emergency', 'features', 'features_sets', 'errors', 'free_time')); }
public function authenticated(Request $request, User $user) { (new User\Logs())->setUserId($user->id)->setTypeUsersLogin()->save(); $profile = Profile::where('user_id', $user->id)->first(); if ($profile !== null) { return redirect('/profile/' . $profile->id); } else { return redirect('/profile/create'); } }