/** * Execute the console command. * * @return mixed */ public function fire(Userbot $userbot) { foreach (config('slack.channels-to-manage') as $channelId) { $channel = Channel::findBySlackId($channelId); $userbot->manageChannel($channel); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { /** @var Group $group */ $group = Group::find($id); if ($group == null) { abort(404); } $otherUsers = User::all(); $menuUsers = []; foreach ($group->users as $user) { $otherUsers = $otherUsers->except($user->id); } foreach ($otherUsers as $user) { $menuUsers[$user->id] = $user->char_name; } $otherChannels = Channel::all(); $menuChannels = []; foreach ($group->channels as $channel) { $otherChannels = $otherChannels->except($channel->id); } foreach ($otherChannels as $channel) { $menuChannels[$channel->id] = $channel->name; } $notOwners = User::all(); $menuOwners = []; $owners = []; foreach ($group->getOwners() as $ownerId) { if ($owner = User::find($ownerId)) { $owners[] = $owner; $notOwners = $notOwners->except($ownerId); } else { $group->removeOwner($ownerId); } } foreach ($notOwners as $owner) { $menuOwners[$owner->id] = $owner->char_name; } return view('admin.groups.show', ['id' => $group->id, 'name' => $group->name, 'channels' => $group->channels, 'users' => $group->users, 'menuUsers' => $menuUsers, 'menuChannels' => $menuChannels, 'admin' => \Auth::user()->admin, 'owners' => $owners, 'menuOwners' => $menuOwners]); }
static function findBySlackId($slack_id) { return Channel::where('slack_id', $slack_id)->first(); }
/** * */ public function getNewChannels() { $channels = $this->slackMonkey->getChannelList(); foreach ($channels as $channel) { Channel::firstOrCreate(['name' => $channel['name'], 'slack_id' => $channel['id'], 'is_group' => false]); } $groups = $this->slackMonkey->getGroupList(); foreach ($groups as $group) { Channel::firstOrCreate(['name' => $group['name'], 'slack_id' => $group['id'], 'is_group' => true]); } }