/** * Show the application dashboard to the user. * * @return Response */ public function index() { $groups = []; /** @var Group $group */ foreach (Group::all() as $group) { if ($group->isOwner($this->user->id)) { $groups[] = $group; } } return view('home', ['name' => $this->user->char_name, 'avatar' => $this->user->getAvatarUrl(), 'email' => $this->user->email, 'slackName' => $this->user->slack_name, 'status' => $this->user->status, 'corp' => $this->user->corp_name, 'alliance' => $this->user->alliance_name, 'charId' => $this->user->char_id, 'groups' => $groups]); }
/** * Execute the console command. * * @return mixed */ public function fire(Userbot $userbot, ApiMonkey $api) { $user = User::create(['char_id' => $this->argument('char_id'), 'char_name' => $api->getCharName($this->argument('char_id')), 'email' => $this->argument('email'), 'password' => Userbot::generatePassword(16), 'next_check' => \Carbon\Carbon::now('UTC')]); $userbot->updateSingle($user->char_id); $userbot->linkSlackMembers(); $user->save(); $this->info('User created and API work done.'); }
public function deleteIndex() { // Delete user $id $id = \Request::input('user_id'); $user = User::find($id); $user->groups()->sync([]); $user->delete(); return redirect('/admin/users'); }
public function handleProviderCallback() { $char = Socialize::with('eveonline')->user(); try { $user = User::where('char_id', $char->id)->firstOrFail(); } catch (ModelNotFoundException $e) { $user = User::createAndFill(['char_id' => $char->id, 'char_name' => $char->name, 'password' => Userbot::generatePassword(16), 'next_check' => \Carbon\Carbon::now('UTC')]); } Auth::login($user, true); return redirect('home'); }
/** * Return a link to the users character portrait. * * @return Response */ public function getPortrait() { if (!$this->checkToken()) { return 'Authentication error'; } try { $user = User::findBySlack($this->requestVars['user_id']); } catch (ModelNotFoundException $e) { return 'User not found. Did you register on the management system yet? If so, try again in 5 minutes, or type /register then try again.'; } if (in_array($this->requestVars['text'], config('eve.avatar_sizes'))) { $suffix = '_' . $this->requestVars['text'] . '.jpg'; } else { $suffix = '_512.jpg'; } $link = config('eve.avatar_url') . $user->char_id . $suffix; $payload = ['channel' => '@' . $this->requestVars['user_name'], 'username' => config('pingbot.ping-bot-name'), 'icon_emoji' => config('pingbot.ping-bot-emoji'), 'text' => $link]; $this->slack->sendMessageToServer($payload); return "Portrait link sent to slackbot DM channel \n" . $link; }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
public function addUserToGroup($groupId) { $group = Group::find($groupId); $group->users()->attach(\Request::input('user')); /* Ajax code added in controller, but not in Javascript. Debating whether it is appropriate to use Ajax in this case. */ if (\Request::ajax()) { $user = User::find(input('user')); return \Response::json(array('status' => 'ok', 'user' => array('id' => $user->id, 'charname' => $user->char_name, 'email' => $user->email))); } return redirect('/admin/groups/' . $groupId); }
/** * Resets all statuses, based on standings, without doing API check first. can be triggered after updating * standings to force a refresh. */ public function readNewStandings() { $users = User::all(); foreach ($users as $user) { $user->updateStatus(); $user->save(); } }
/** * @param array $charArray * * @return User */ public static function createAndFill($charArray) { $user = User::create($charArray); $userbot = new Userbot(); $userbot->updateSingle($charArray['char_id']); return $user; }