<?php
/**
 * Repository Class
 *
 * Wegen individueller Methoden aus der automatischen Generierung genommen.
 *
 * @todo        Standardfilter (active, internal) fix machen und überflüssige Parameter entfernen.
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @subpackage  Repositories
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Repositories;


use BplanBase\Globals\Foundation\Repositories\BaseIndexCollectionRepository;
use BplanBase\Globals\Models\Country;
use BplanBase\Globals\Models\Language;
use BplanBase\Globals\Models\Location;
use BplanBase\Globals\Models\LocationType;
use BplanBase\Globals\Models\Module;
use BplanBase\Globals\Models\PrintJob;
use BplanBase\Globals\Models\Printer;
use BplanBase\Globals\Models\PrinterType;
use BplanBase\Globals\Models\Role;
use BplanBase\Globals\Models\Setting;
use BplanBase\Globals\Models\Tenant;
use BplanBase\Globals\Models\TenantRecord;
use BplanBase\Globals\Models\User;
use BplanBase\Globals\ValueObjects\PaginateArgs;
use Closure;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Pagination\LengthAwarePaginator;


/**
 * Repository Class
 *
 * @version     6.0.0 / 2026-06-08
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class IndexCollectionRepository extends BaseIndexCollectionRepository
{


/* +++ TRAITS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS CONSTANTS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT MEMBERS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS MEMBERS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT METHODS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS METHODS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<Country>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getCountries(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Country::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($orderBy === null) {
            $orderBy = 'short_names';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getCountries()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<Language>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getLanguages(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Language::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getLanguages()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be read out.
     *
     * @param       bool $withInternal
     *              By default, only the data records marked as “internal = 0” are read out. By
     *              setting this parameter to TRUE, the internal status is ignored and all data
     *              records are read.
     *
     * @return      Collection|LengthAwarePaginator<Location>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getLocations(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false, bool $withInternal = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Location::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($withInternal === false) {
            $Query->noInternal();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getLocations()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<LocationType>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getLocationTypes(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(LocationType::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getLocationTypes()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @param       bool $withInternal
     *              By default, internal data records are excluded. By
     *              setting this parameter to TRUE, internal data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<Module>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getModules(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false, bool $withInternal = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Module::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($withInternal === false) {
            $Query->noInternal();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getModules()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @return      Collection|LengthAwarePaginator<PrintJob>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getPrintJobs(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(PrintJob::class, $ExtendQuery);

        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getPrintJobs()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<PrinterType>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getPrinterTypes(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(PrinterType::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getPrinterTypes()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<Printer>
     *
     * @version     1.0.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getPrinters(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Printer::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getPrinters()


    /**
     * Returns a paginated collection of roles for the current tenant.
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *
     * @param       array|bool|int $paginate
     *
     * @param       bool $withInactive
     *
     * @param       bool $withInternal
     *
     * @return      Collection|LengthAwarePaginator<Role>
     *
     * @version     1.0.0 / 2026-06-08
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getRoles(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false, bool $withInternal = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Role::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($withInternal === false) {
            $Query->noInternal();
        }
        if ($orderBy === null) {
            $orderBy = 'name';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getRoles()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @return      Collection|LengthAwarePaginator<Setting>
     *
     * @version     1.1.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getSettings(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Setting::class, $ExtendQuery);

        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getSettings()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @return      Collection|LengthAwarePaginator<TenantRecord>
     *
     * @version     1.1.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getTenantRecords(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(TenantRecord::class, $ExtendQuery);

        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getTenantRecords()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @param       bool $withInternal
     *              By default, internal data records are excluded. By
     *              setting this parameter to TRUE, internal data records can
     *              also be included.
     *
     * @return      Collection|LengthAwarePaginator<Tenant>
     *
     * @version     1.1.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getTenants(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false, bool $withInternal = false): Collection|LengthAwarePaginator
    {
        $Query = self::_resolveQuery(Tenant::class, $ExtendQuery);

        if ($withInactive === false) {
            $Query->active();
        }
        if ($withInternal === false) {
            $Query->noInternal();
        }
        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getTenants()


    /**
     * Returns a collection of models
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @param       array|string|null $orderBy
     *              @see BplanBase\Globals\Helpers\QueryHelper::applyOrderBy() for
     *              details.
     *
     * @param       array|bool|int $paginate
     *              Can be either the number of elements, TRUE or an array. If
     *              TRUE is passed, the default number from the configuration is
     *              used. If an array is passed, then all known arguments for
     *              paginate() (columns, page, pageName, perPage, total) can be
     *              specified in it (all optional).
     *              @see https://api.laravel.com/docs/12.x/Illuminate/Database/Eloquent/Builder.html#method_paginate
     *
     * @param       bool $withInactive
     *              By default, only the active data records are returned. By
     *              setting this parameter to TRUE, the inactive data records can
     *              also be included.
     *
     * @param       bool $withInternal
     *              By default, only the data records marked as “internal = 0” are read out. By
     *              setting this parameter to TRUE, the internal status is ignored and all data
     *              records are read.
     *
     * @return      Collection|LengthAwarePaginator<User>
     *
     * @version     1.1.1 / 2026-06-08
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function getUsers(Builder|Closure|null $ExtendQuery = null, array|string|null $orderBy = null, array|bool|int $paginate = false, bool $withInactive = false, bool $withInternal = false): Collection|LengthAwarePaginator
    {
        $Query = User::query();

        if ($withInactive === false) {
            $Query->active();
        }
        if ($withInternal === false) {
            $Query->noInternal();
        }
        $Query = self::_extendQuery($ExtendQuery, $Query);

        if ($orderBy === null) {
            $orderBy = 'id';
        }
        $Query->ordered($orderBy);

        $PaginateArgs = PaginateArgs::from($paginate);

        if ($PaginateArgs->isPaginated() === false) {
            return $Query->get();
        }
        return $Query->paginate(...$PaginateArgs->toArray());

    } // getUsers()


} // class IndexCollectionRepository extends BaseIndexCollectionRepository {}
