src/Gzero/Cms/Repositories/BlockReadRepository.php
public function getVisibleBlocks(array $ids, Language $language, $onlyActive = true)
    {
        $query = Block::query()->with(self::$loadRelations);

        if (!empty($ids)) {
            $query->where(function ($query) use ($ids) {
                $query->whereIn('id', $ids)
                    ->orWhere('filter', null);
            });

        } else { // blocks on all pages only
            $query->where('filter', null);
        }

        if ($onlyActive) {
            $query->whereHas('translations', function ($query) use ($language) {
                $query->where('block_translations.is_active', true)
                    ->where('language_code', $language->code);
            })->where('is_active', '=', true);
        }

        $blocks = $query->orderBy('weight', 'ASC')->get();

        return $blocks;
    }
public function getVisibleBlocks(array $ids, Language $language, $onlyActive = true)
    {
        $query = Block::query()->with(self::$loadRelations);

        if (!empty($ids)) {
            $query->where(function ($query) use ($ids) {
                $query->whereIn('id', $ids)
                    ->orWhere('filter', null);
            });

        } else { // blocks on all pages only
            $query->where('filter', null);
        }

        if ($onlyActive) {
            $query->whereHas('translations', function ($query) use ($language) {
                $query->where('block_translations.is_active', true)
                    ->where('language_code', $language->code);
            })->where('is_active', '=', true);
        }

        $blocks = $query->orderBy('weight', 'ASC')->get();

        return $blocks;
    }
public function getVisibleBlocks ( array $ ids , Language $ language , $ onlyActive = true ) { $ query = Block :: query ( ) -> with ( self :: $ loadRelations ) ; if ( ! empty ( $ ids ) ) { $ query -> where ( function ( $ query ) use ( $ ids ) { $ query -> whereIn ( 'id' , $ ids ) -> orWhere ( 'filter' , null ) ; } ) ; } else { // blocks on all pages only $ query -> where ( 'filter' , null ) ; } if ( $ onlyActive ) { $ query -> whereHas ( 'translations' , function ( $ query ) use ( $ language ) { $ query -> where ( 'block_translations.is_active' , true ) -> where ( 'language_code' , $ language -> code ) ; } ) -> where ( 'is_active' , '=' , true ) ; } $ blocks = $ query -> orderBy ( 'weight' , 'ASC' ) -> get ( ) ; return $ blocks ; }
Returns all visible blocks

@param array    $ids        Array with blocks ids returned from block finder
@param Language $language   Language
@param bool     $onlyActive Return only active blocks

@return Collection
Returns all visible blocks