@param \Illuminate\Support\Collection $universe_name

@param int                            $character_id

@return string
773684
private function getCorporationIntelView(Collection $universe_name, int $character_id) : string
    {
        if ($universe_name->has('unknown_id'))
            return $this->getUnknownIntelView($universe_name);

        if (! $universe_name->has('corporation_id'))
            return '';

        $corporation = CorporationInfo::find($universe_name['corporation_id']) ?: $universe_name['corporation_id'];

        return view('web::partials.corporation', compact('corporation', 'character_id'));
    }
970669
private function doGenerate($fullName, $characterLimit, array $characters = array())
    {
        $balineseGenerator = new BalinesePetrukUsername();
        if (-1 !== $balineseGenerator->isReservedName($fullName)) {
            $characters = array_merge($characters, $balineseGenerator->generate($fullName, $characterLimit));
        }

        $islamicGenerator = new IslamicPetrukUsername();
        if (-1 !== $islamicGenerator->isReservedName($fullName)) {
            $characters = array_merge($characters, $islamicGenerator->generate($fullName, $characterLimit));
        }

        $westernGenerator = new WesternPetrukUsername();
        if (-1 !== $westernGenerator->isReservedName($fullName)) {
            $characters = array_merge($characters, $westernGenerator->generate($fullName, $characterLimit));
        }

        $genericGenerator = new GenericPetrukUsername();
        $characters = array_merge($characters, $genericGenerator->generate($fullName, $characterLimit));

        return $characters;
    }
894754
public function getCharacterMailMessage(int $character_id, int $message_id): MailHeader
    {

        return MailHeader::where('character_id', $character_id)
            ->where('mail_id', $message_id)
            ->orderBy('timestamp', 'desc')
            ->first();
    }
704244
public static function calFromJd($julian_day, $calendar_id)
    {
        switch ($calendar_id) {
            case CAL_FRENCH:
                return self::calFromJdCalendar($julian_day, self::jdToFrench($julian_day), self::$MONTH_NAMES_FRENCH, self::$MONTH_NAMES_FRENCH);

            case CAL_GREGORIAN:
                return self::calFromJdCalendar($julian_day, self::jdToGregorian($julian_day), self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT);

            case CAL_JEWISH:
                $months = self::jdMonthNameJewishMonths($julian_day);

                $cal = self::calFromJdCalendar($julian_day, self::jdToCalendar(self::$jewish_calendar, $julian_day, 347998, 324542846), $months, $months);

                if (($julian_day < 347998 || $julian_day > 324542846) && !self::shouldEmulateBug67976()) {
                    $cal['dow'] = null;
                    $cal['dayname'] = '';
                    $cal['abbrevdayname'] = '';
                }

                return $cal;

            case CAL_JULIAN:
                return self::calFromJdCalendar($julian_day, self::jdToJulian($julian_day), self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT);

            default:
                return trigger_error('invalid calendar ID ' . $calendar_id, E_USER_WARNING);
        }
    }
1306553
public static function calInfo($calendar_id)
    {
        switch ($calendar_id) {
            case CAL_FRENCH:
                return self::calInfoCalendar(self::$MONTH_NAMES_FRENCH, self::$MONTH_NAMES_FRENCH, 30, 'French', 'CAL_FRENCH');

            case CAL_GREGORIAN:
                return self::calInfoCalendar(self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT, 31, 'Gregorian', 'CAL_GREGORIAN');

            case CAL_JEWISH:
                $months = self::shouldEmulateBug54254() ? self::$MONTH_NAMES_JEWISH_54254 : self::$MONTH_NAMES_JEWISH_LEAP_YEAR;

                return self::calInfoCalendar($months, $months, 30, 'Jewish', 'CAL_JEWISH');

            case CAL_JULIAN:
                return self::calInfoCalendar(self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT, 31, 'Julian', 'CAL_JULIAN');

            case -1:
                return array(
                CAL_GREGORIAN => self::calInfo(CAL_GREGORIAN),
                CAL_JULIAN    => self::calInfo(CAL_JULIAN),
                CAL_JEWISH    => self::calInfo(CAL_JEWISH),
                CAL_FRENCH    => self::calInfo(CAL_FRENCH),
            );

            default:
                return trigger_error('invalid calendar ID ' . $calendar_id, E_USER_WARNING);
        }
    }
239022
public function Table($Name = '', $CharacterEncoding = '') {
		if(!$Name)
			return $this->_TableName;
		
      $this->_TableName = $Name;
      if ($CharacterEncoding == '')
         $CharacterEncoding = Gdn::Config('Database.CharacterEncoding', '');

      $this->_CharacterEncoding = $CharacterEncoding;
      return $this;
   }
1309117
public function getCharacter4Id($id)
    {
        /** @var \GameBackend\Entity\CrossFire\Repository\Character $repository */
        $repository = $this->getAccountEntityManager()->getRepository($this->getGameOptions()->getEntityCharacterClass());
        return $repository->getCharacter4Id($id);
    }
979811
public function getCharacterContracts(Collection $character_ids) : Builder
    {

        return DB::table(DB::raw('contract_details as a'))
            ->select(DB::raw(
                '
                --
                -- All Columns
                --
                *,

                --
                -- Start Location Lookup
                --
                CASE
                when a.start_location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id-6000000)
                when a.start_location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id-6000001)
                when a.start_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 = a.start_location_id-6000000)
                when a.start_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 = a.start_location_id)
                when a.start_location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id)
                when a.start_location_id >= 61000000 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.start_location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID = a.start_location_id) end
                AS startlocation,

                --
                -- End Location Lookup
                --
                CASE
                when a.end_location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id-6000000)
                when a.end_location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id-6000001)
                when a.end_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 = a.end_location_id-6000000)
                when a.end_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 = a.end_location_id)
                when a.end_location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id)
                when a.end_location_id >= 61000000 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.end_location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID = a.end_location_id) end
                AS endlocation '))
            ->join('character_contracts', 'character_contracts.contract_id', '=', 'a.contract_id')
            ->whereIn('character_contracts.character_id', $character_ids->toArray());

    }
973518
public function getTopMailFromData(int $character_id)
    {
        if (! request()->has('all_linked_characters'))
            return abort(500);

        $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;

        $top = $this->characterTopMailInteractions($character_ids);

        return DataTables::of($top)
            ->editColumn('character_id', function ($row) {

                return $this->getIntelView('character', $row->character_id, $row->from);
            })
            ->editColumn('corporation_id', function ($row) {

                return $this->getIntelView('corporation', $row->character_id, $row->from);
            })
            ->editColumn('alliance_id', function ($row) {

                return $this->getIntelView('alliance', $row->character_id, $row->from)
                    . view('web::character.intel.partials.mailcontentbutton', compact('row'));
            })
            ->rawColumns(['character_id', 'corporation_id', 'alliance_id'])
            ->make(true);
    }
1320076
public function getMailData(int $character_id)
    {

        if (! request()->has('all_linked_characters'))
            return abort(500);

        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;

        $mail = $this->getCharacterMail($character_ids);

        return DataTables::of($mail)
            ->editColumn('from', function ($row) {

                $character_id = $row->character_id;

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

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

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

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

                return view('web::character.partials.mailread', compact('row'));

            })
            ->rawColumns(['from', 'subject', 'tocounts', 'read'])
            ->make(true);

    }
818595
public function getPi(int $character_id)
    {

        $colonies = $this->getCharacterPlanetaryColonies($character_id);
        $extractors = $this->getCharacterPlanetaryExtractors($character_id);

        // TODO: Complete the Links and stuff™

        return view('web::character.pi', compact('colonies', 'extractors'));
    }
759928
public function getCharacterMarketOrders(Collection $character_ids) : Builder
    {

        return DB::table(DB::raw('character_orders as a'))
            ->select(DB::raw(
                '
                --
                -- Select All
                --
                *,

                --
                -- Start stationName Lookup
                --
                CASE
                when a.location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.location_id-6000000)
                when a.location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.location_id-6000001)
                when a.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 = a.location_id-6000000)
                when a.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 = a.location_id)
                when a.location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.location_id)
                when a.location_id >= 61000000 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID = a.location_id) end
                    AS stationName'))
            ->join(
                'invTypes',
                'a.type_id', '=',
                'invTypes.typeID')
            ->whereIn('a.character_id', $character_ids);

    }
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());

    }
306051
public function getCharacterIndustry(int $character_id, bool $get = true)
    {

        $industry = DB::table('character_industry_jobs as a')
            ->select(DB::raw('
                a.*,
                ramActivities.*,
                blueprintType.typeName as blueprintTypeName,
                productType.typeName as productTypeName,

                --
                -- Start Facility Name Lookup
                --
                CASE
                when a.station_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.station_id-6000000)
                when a.station_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.station_id-6000001)
                when a.station_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 = a.station_id-6000000)
                when a.station_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 = a.station_id)
                when a.station_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.station_id)
                when a.station_id >= 61000000 then
                    (SELECT c.name FROM `universe_structures` AS c
                      WHERE c.structure_id = a.station_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                WHERE m.itemID = a.station_id) end
                AS facilityName'))
            ->leftJoin(
                'ramActivities',
                'ramActivities.activityID', '=',
                'a.activity_id')// character_industry_jobs aliased to a
            ->join(
                'invTypes as blueprintType',
                'blueprintType.typeID', '=',
                'a.blueprint_type_id'
            )
            ->join(
                'invTypes as productType',
                'productType.typeID', '=',
                'a.product_type_id'
            )
            ->where('a.character_id', $character_id);

        if ($get)
            return $industry->orderBy('end_date', 'desc')
                ->get();

        return $industry;

    }
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);

    }
379772
private function getCharacterId($char_name_area)
    {
        $char_id = $char_name_area->find('a', 0)->href;
        $char_id = explode('/', $char_id);

        return $char_id[4];
    }
1064097
public function getCharacterLedger(Collection $character_ids) : Builder
    {

        return CharacterMining::with('type', 'system')
            ->select(
                'character_minings.date',
                'character_minings.character_id',
                'solar_system_id',
                'character_minings.type_id',
                'historical_prices.adjusted_price')
            ->leftJoin('historical_prices', function ($join) {
                $join->on('historical_prices.type_id', '=', 'character_minings.type_id')
                     ->on('historical_prices.date', '=', 'character_minings.date');
            })
            ->whereIn('character_id', $character_ids->toArray());
    }