src/Repositories/Character/Character.php
public function getAllCharactersWithAffiliations(bool $get = true)
    {

        // TODO : rewrite the method according to the new ACL mechanic

        // Get the User for permissions and affiliation
        // checks
        $user = auth()->user();

        // Which characters does the currently logged in user have?
        $user_character_ids = auth()->user()->associatedCharacterIds();

        // Start the character information query
        $characters = new CharacterInfo;

        // If the user is not a super user, return only the characters the
        // user has access to.
        if (! $user->hasSuperUser()) {

            $characters = $characters->where(function ($query) use ($user, $user_character_ids) {

                // If the user has any affiliations and can
                // list those characters, add them
                if ($user->has('character.list', false))
                    $query->orWhereIn('character_id',
                        array_keys($user->getAffiliationMap()['char']));

                $query->orWhereIn('character_id', $user_character_ids);
            });

        }

        if ($get)
            return $characters
                ->orderBy('name')
                ->get();

        return $characters->getQuery();
    }
public function getAllCharactersWithAffiliations(bool $get = true)
    {

        // TODO : rewrite the method according to the new ACL mechanic

        // Get the User for permissions and affiliation
        // checks
        $user = auth()->user();

        // Which characters does the currently logged in user have?
        $user_character_ids = auth()->user()->associatedCharacterIds();

        // Start the character information query
        $characters = new CharacterInfo;

        // If the user is not a super user, return only the characters the
        // user has access to.
        if (! $user->hasSuperUser()) {

            $characters = $characters->where(function ($query) use ($user, $user_character_ids) {

                // If the user has any affiliations and can
                // list those characters, add them
                if ($user->has('character.list', false))
                    $query->orWhereIn('character_id',
                        array_keys($user->getAffiliationMap()['char']));

                $query->orWhereIn('character_id', $user_character_ids);
            });

        }

        if ($get)
            return $characters
                ->orderBy('name')
                ->get();

        return $characters->getQuery();
    }
public function getAllCharactersWithAffiliations ( bool $ get = true ) { // TODO : rewrite the method according to the new ACL mechanic // Get the User for permissions and affiliation // checks $ user = auth ( ) -> user ( ) ; // Which characters does the currently logged in user have? $ user_character_ids = auth ( ) -> user ( ) -> associatedCharacterIds ( ) ; // Start the character information query $ characters = new CharacterInfo ; // If the user is not a super user, return only the characters the // user has access to. if ( ! $ user -> hasSuperUser ( ) ) { $ characters = $ characters -> where ( function ( $ query ) use ( $ user , $ user_character_ids ) { // If the user has any affiliations and can // list those characters, add them if ( $ user -> has ( 'character.list' , false ) ) $ query -> orWhereIn ( 'character_id' , array_keys ( $ user -> getAffiliationMap ( ) [ 'char' ] ) ) ; $ query -> orWhereIn ( 'character_id' , $ user_character_ids ) ; } ) ; } if ( $ get ) return $ characters -> orderBy ( 'name' ) -> get ( ) ; return $ characters -> getQuery ( ) ; }
Query the database for characters, keeping filters,
permissions and affiliations in mind.

@param bool $get

@return mixed
Query the database for characters keeping filters permissions and affiliations in mind .