@param int $character_id

@return mixed
@throws \Exception
184219
public function getJournalData(int $character_id)
    {
        if (! request()->has('all_linked_characters'))
            return response('required url parameter is missing!', 400);

        if (request('all_linked_characters') === 'false')
            $character_ids = collect($character_id);

        $user_group = User::find($character_id)->group->users
            ->filter(function ($user) {
                return $user->name !== 'admin' && $user->id !== 1;
            })
            ->pluck('id');

        if (request('all_linked_characters') === 'true')
            $character_ids = $user_group;

        $journal = $this->getCharacterWalletJournal($character_ids);

        return DataTables::of($journal)
            ->editColumn('ref_type', function ($row) {

                return view('web::partials.journaltranstype', compact('row'));
            })
            ->editColumn('first_party_id', function ($row) {

                $character_id = $row->character_id;

                if (optional($row->first_party)->category === 'character') {

                    $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id;

                    return view('web::partials.character', compact('character', 'character_id'));
                }

                if (optional($row->first_party)->category === 'corporation'){

                    $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id;

                    return view('web::partials.corporation', compact('corporation', 'character_id'));
                }

                return view('web::partials.unknown', [
                    'unknown_id' => $row->first_party_id,
                    'character_id' => $character_id,
                ]);
            })
            ->editColumn('second_party_id', function ($row) {

                $character_id = $row->character_id;

                if (optional($row->second_party)->category === 'character') {

                    $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id;

                    return view('web::partials.character', compact('character', 'character_id'));
                }

                if (optional($row->second_party)->category === 'corporation') {

                    $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id;

                    return view('web::partials.corporation', compact('corporation', 'character_id'));
                }

                return view('web::partials.unknown', [
                    'unknown_id' => $row->second_party_id,
                    'character_id' => $character_id,
                ]);
            })
            ->editColumn('amount', function ($row) {

                return number($row->amount);
            })
            ->editColumn('balance', function ($row) {

                return number($row->balance);
            })
            ->addColumn('is_in_group', function ($row) use ($user_group) {

                return in_array($row->first_party_id, $user_group->toArray()) && in_array($row->second_party_id, $user_group->toArray());
            })
            ->rawColumns(['ref_type', 'first_party_id', 'second_party_id'])
            ->make(true);

    }
1163988
public function getNextId()
    {
        $sql   = 'UPDATE ' . $this->table . ' SET value = LAST_INSERT_ID(value + 1) WHERE name = ?';

        $result   = $this->db->query($sql, array($this->name));
        $rowCount = $result->rowCount();

        if (1 !== $rowCount) {
            throw new Exception("Sequence '" . $this->name . "' not found.");
        }

        $createdId = $this->db->lastInsertId();

        return (int) $createdId;
    }
1015100
public function getCompareStandingsWithProfileData(int $character_id, int $profile_id)
    {

        $journal = $this->getCharacterJournalStandingsWithProfile($character_id, $profile_id);

        return DataTables::of($journal)
            ->editColumn('characterName', function ($row) {

                return view('web::character.intel.partials.charactername', compact('row'))
                    ->render();
            })
            ->editColumn('corporationName', function ($row) {

                return view('web::character.intel.partials.corporationname', compact('row'))
                    ->render();
            })
            ->editColumn('allianceName', function ($row) {

                return view('web::character.intel.partials.alliancename', compact('row'))
                    ->render();
            })
            ->rawColumns(['characterName', 'corporationName', 'allianceName'])
            ->make(true);

    }
977195
public function getDetailedLedger(int $character_id, $date, int $system_id, int $type_id): JsonResponse
    {
        if (! request()->has('all_linked_characters'))
            return abort(500);

        $character_ids = collect($character_id);

        $entries = $this->getCharacterLedger($character_ids)
            ->addSelect('time', 'quantity')
            ->where('character_minings.date', $date)
            ->where('solar_system_id', $system_id)
            ->where('character_minings.type_id', $type_id)
            ->get();

        return DataTables::of($entries)
            ->removeColumn('solar_system_id')
            ->removeColumn('date')
            ->removeColumn('type_id')
            ->removeColumn('average_price')
            ->removeColumn('type')
            ->editColumn('quantity', function ($row) {

                return view('web::partials.miningquantity', compact('row'));
            })
            ->editColumn('volume', function ($row) {

                return view('web::partials.miningvolume', compact('row'));
            })
            ->addColumn('value', function ($row) {

                $value = $row->average_price * $row->quantity;

                if(empty($value))
                    // If historical price has not been set, get historical price.
                    $value = $this->getHistoricalPrice($row->type_id, $row->date)->average_price;

                return view('web::partials.miningvalue', compact('value'));
            })
            ->rawColumns(['value', 'volume'])
            ->make(true);
    }
367807
public function getSkills(int $character_id)
    {

        $skills = $this->getCharacterSkillsInformation($character_id);
        $skill_groups = $this->getEveSkillsGroups();

        return view('web::character.skills',
            compact('skills', 'skill_groups'));
    }
1185557
public function loadByACLID($id)
    {
        $parts = explode("#", $id);
        if (count($parts) !== 2)
            throw new Exception("Invalid DAO ID: {$id}");
    
        if (!isset($this->classes[$parts[0]]))
            throw new Exception("Invalid DAO type: {$parts[0]}");
    
        $classname = $this->classes[$parts[0]];
        $pkey_values = explode("-", $parts[1]);

        $db = DB::getInstance();
        $dao = $db->getDAO($classname);
    
        return call_user_func(array($dao, "get"), $pkey_values);
    }
446073
private function getUniverseNameResolved(int $character_id, int $first_party_id, int $second_party_id = null) : Collection
    {
        // f.e. market escrow -> self referential payment.
        if($first_party_id === $second_party_id)
            return collect([
                'character_id' => $character_id,
                'corporation_id' => CharacterInfo::find($character_id)->corporation_id,
                'alliance_id' => CharacterInfo::find($character_id)->alliance_id,
            ]);

        return collect([UniverseName::find($first_party_id), UniverseName::find($second_party_id)])
            ->filter()
            ->filter(function ($universe_name) use ($character_id) {

                return $universe_name->entity_id !== $character_id;
            })
            ->pipe(function ($collection) use ($character_id, $first_party_id,$second_party_id) {

                if ($collection->isNotEmpty()){

                    return $collection->flatten()->map(function ($item) {

                        if($item->category === 'character')
                            return collect([
                                'character_id' => $item->entity_id,
                                'corporation_id' => optional(CharacterAffiliation::find($item->entity_id))->corporation_id,
                                'alliance_id' => optional(CharacterAffiliation::find($item->entity_id))->alliance_id,
                            ])->filter();

                        if($item->category === 'corporation')
                            return collect([
                                'corporation_id' => $item->entity_id,
                                'alliance_id' => optional(CharacterAffiliation::where('corporation_id', $item->entity_id)->get()->first())->alliance_id,
                            ])->filter();

                        if($item->category === 'alliance')
                            return collect(['alliance_id' => $item->entity_id]);

                        return collect(['other_resolved_id' => $item->entity_id]);
                    })->filter();
                }

                return $collection->push(collect(['unknown_id' => $character_id !== $first_party_id ? $first_party_id : $second_party_id, 'character_id' => $character_id]));
            })
            ->flatMap(function ($value) {

                return $value;
            });
    }
857968
public function getCharacterWalletTransactions(Collection $character_ids) : Builder
    {

        return CharacterWalletTransaction::with('client', 'type')
            ->select(DB::raw('
            *, CASE
                when character_wallet_transactions.location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID=character_wallet_transactions.location_id-6000000)
                when character_wallet_transactions.location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID=character_wallet_transactions.location_id-6000001)
                when character_wallet_transactions.location_id BETWEEN 66014934 AND 67999999 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id=character_wallet_transactions.location_id-6000000)
                when character_wallet_transactions.location_id BETWEEN 60014861 AND 60014928 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id=character_wallet_transactions.location_id)
                when character_wallet_transactions.location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID=character_wallet_transactions.location_id)
                when character_wallet_transactions.location_id BETWEEN 61000000 AND 61001146 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id=character_wallet_transactions.location_id)
                when character_wallet_transactions.location_id > 61001146 then
                    (SELECT name FROM `universe_structures` AS c
                     WHERE c.structure_id = character_wallet_transactions.location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID=character_wallet_transactions.location_id) end
                AS locationName'
            ))
            ->whereIn('character_id', $character_ids->toArray());

    }
1278216
public function getUid()
    {
        if (!array_key_exists(self::UID, $this->passwd)) {
            throw new \Exception('Could not get user id from passwd.');
        }
        return $this->passwd[self::UID];
    }
110957
public function extractId() {
        $regex = '/[\'"]id[\'"] *: *([0-9]*)/';
        $rawData = $this->getRawPostData();
        if (preg_match($regex, $rawData, $m)) {
            return intval($m[1]);
        } else {
            return null;
        }
    }
861217
public function getDeleteNote(int $character_id, int $note_id)
    {

        CharacterInfo::deleteNote($character_id, $note_id);

        return redirect()->back()
            ->with('success', 'Note deleted!');

    }
1063947
public function getDispatchUpdateJob(int $character_id, string $job_name)
    {

        $job_classes = collect(config('web.jobnames.' . $job_name));

        // If we could not find the jon to dispatch, log this as a
        // security event as someone might be trying something funny.
        if ($job_classes->isEmpty()) {

            $message = 'Failed to find the jobclass for job_name ' . $job_name .
                ' Someone might be trying something strange.';

            event('security.log', [$message, 'jobdispatching']);

            return redirect()->back()->with('warning', trans('web::seat.update_failed'));
        }

        // Find the refresh token for the jobs.
        $refresh_token = RefreshToken::findOrFail($character_id);

        // Dispatch jobs for each jobclass
        $job_classes->each(function ($job) use ($refresh_token, $character_id) {

            (new $job($refresh_token))->dispatch($refresh_token)->onQueue('high');

            logger()->info('Manually dispatched job \'' . $job . '\' for character ' .
                $character_id);
        });

        // Redirect back!
        return redirect()->back()->with('success', trans('web::seat.update_dispatched'));
    }
352090
public function asCharacterString(): Primitive\CharacterString
    {
        if (!$this->_element instanceof Primitive\CharacterString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING));
        }
        return $this->_element;
    }
624559
private function getAPIData($charId) {
        $url = 'https://api.eveonline.com/eve/CharacterInfo.xml.aspx?characterID='.(int)$charId;
        $data = file_get_contents($url);
        $xml = simplexml_load_string($data);
        return $xml->result;
    }
68142
public function getContacts(int $character_id)
    {

        if(! request()->ajax())
            return view('web::character.contacts');

        if(! request()->has('all_linked_characters'))
            return response('required url parameter is missing!', 400);

        if(request('all_linked_characters') === 'false')
            $character_ids = collect($character_id);

        $user_group = User::find($character_id)->group->users
            ->filter(function ($user) {
                if(! $user->name === 'admin' || $user->id === 1)
                    return false;

                return true;
            })
            ->pluck('id');

        if(request('all_linked_characters') === 'true')
            $character_ids = $user_group;

        $standings = array_map('intval', explode(',', request('selected_standings')));

        $contacts = $this->getCharacterContacts($character_ids, $standings);

        return DataTables::of($contacts)
            ->editColumn('name', function ($row) {

                $character_id = $row->character_id;

                if($row->contact_type === 'character'){
                    $character = CharacterInfo::find($row->contact_id) ?: $row->contact_id;

                    return view('web::partials.character', compact('character', 'character_id'));
                }

                if($row->contact_type === 'corporation'){
                    $corporation = CorporationInfo::find($row->contact_id) ?: $row->contact_id;

                    return view('web::partials.corporation', compact('corporation', 'character_id'));
                }

                return view('web::partials.unknown', [
                    'unknown_id' => $row->contact_id,
                    'character_id' => $character_id,
                    ]);
            })
            ->editColumn('label_ids', function ($row) {

                if(isset($row->label_ids)) {
                    $labels = $this->getCharacterContactLabels($row->character_id);

                    return $labels->whereIn('label_id', $row->label_ids)->implode('label_name', ', ');
                }

                return '';
            })
            ->addColumn('standing_view', function ($row) {

                if($row->standing > 0)
                    return "<b class='text-success'>" . $row->standing . '</b>';

                if($row->standing < 0)
                    return "<b class='text-danger'>" . $row->standing . '</b>';

                return '<b>' . $row->standing . '</b>';

            })
            ->addColumn('links', function ($row) {

                return view('web::partials.links', ['id' => $row->contact_id, 'type' => $row->contact_type]);
            })
            ->addColumn('is_in_group', function ($row) use ($user_group) {

                return $user_group->intersect(collect($row->contact_id))->isNotEmpty();
            })
            ->filterColumn('name', function ($query, $keyword) {
                $resolved_ids = UniverseName::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($resolved_id) { return $resolved_id->entity_id; });
                $character_info_ids = CharacterInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($character_info) { return $character_info->character_id; });
                $corporation_info_ids = CorporationInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($corporation_info) { return $corporation_info->corproation_id; });

                $query->whereIn('contact_id', array_merge($resolved_ids->toArray(), $character_info_ids->toArray(), $corporation_info_ids->toArray()));
            })
            ->filterColumn('label_ids', function ($query, $keyword) use ($character_ids) {

                $labels = CharacterContactLabel::where('label_name', 'like', '%' . $keyword . '%')
                    ->whereIn('character_id', $character_ids)
                    ->get();

                foreach ($labels as $label)
                    $query->whereRaw(DB::raw('JSON_CONTAINS(label_ids, ' . $label->label_id . ')'));
            })
            ->rawColumns(['name', 'standing_view', 'links'])
            ->make(true);

    }
317604
public function getContractsItemsData(int $character_id, int $contract_id)
    {

        $assets = $this->getCharacterContractsItems($character_id, $contract_id);

        return view('web::character.contractitems', compact('assets'));
    }
467948
public function getChatId($chat_id = null) {
        try {
            if ($chat_id)
                return $chat_id;

            if( isset($this->result->message) ) {
                return $this->result->message->chat->id;
            } elseif ( isset($this->result->inline_query) ) {
                return $this->result->inline_query->from->id;
            } else {
                throw new \Exception("Error Processing Request", 1);
            }
        } catch (\Exception $e) {
            error_log($e->getMessage());
        }
    }