<?php
/**
 * Eloquent Helper Class
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @subpackage  Helpers
 * @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\Helpers;


use Closure;
use BplanBase\Globals\Support\Eloquent as SupportEloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;


/**
 * Eloquent Helper Class
 *
 * @deprecated  Use BplanBase\Globals\Eloquent instead
 *
 * @version     2.0.0 / 2026-03-12
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class EloquentHelper
{


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


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


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


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


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


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


    /**
     * Returns a collection with ID => attribute value based on language code and fallback
     *
     * @deprecated  Use BplanBase\Globals\Eloquent::getLocalizedCollection() instead
     *
     * @param       Builder|string $classOrBuilder
     *              Can be either an instance of Illuminate\Database\Eloquent\Builder or
     *              a fully qualified class name of a model class.
     *
     * @param       string $locale
     *              The desired locale.
     *
     * @param       string $attribute
     *              The name of a Json attribute.
     *
     * @param       null|string $fallbackAttribute = null
     *              If no $fallbackAttribute is passed, then 'id' is used.
     *
     * @param       null|string $fallbackLocale = null
     *              If no $fallbackLocale is passed, then config('app.fallback_locale', 'en')
     *              is used.
     *
     * @return      Collection
     *
     * @version     1.0.0 / 2025-05-29
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     *
     */
    public static function getLocalizedCollection(Builder|string $classOrBuilder, string $locale, string $attribute, null|string $fallbackAttribute = null, null|string $fallbackLocale = null): Collection
    {
        return SupportEloquent::getLocalizedCollection($classOrBuilder, $locale, $attribute, $fallbackAttribute, $fallbackLocale);

    } // getLocalizedCollection()


    /**
     *
     * @deprecated  Use BplanBase\Globals\Eloquent::resolveQuery() instead
     *
     * @param       string $modelClass
     *
     * @param       Builder|Closure|null $ExtendQuery
     *
     * @throws      InvalidArgumentException
     *
     * @return      Builder
     *
     * @version     1.0.0 / 2026-03-12
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public static function resolveQuery(string $modelClass, Builder|Closure|null $Query = null): Builder
    {
        return SupportEloquent::resolveQuery($modelClass, $Query);

    } // resolveQuery()


} // class EloquentHelper {}
