<?php
/**
 * Created by PhpStorm.
 * User: steven
 * Date: 12/6/18
 * Time: 1:27 PM
 */

namespace Hilco\Models;


class Translations_WebCollection extends WebModel
{
    protected $table = "Translations_WebCollections";

    public static function getTranslationByWebCollectionId($webCollectionId){
        $activeLanguage = b2b()->activeLanguage();
        if(isset($webCollectionId)){
            $activeWebTranslations = b2b()->activeWebTranslations();
            if(isset($activeWebTranslations)){
                $webCollectionTranslations = $activeWebTranslations['webCollectionTranslations'];
                $translation = $webCollectionTranslations->filter(function($value, $key) use ($webCollectionId){
                    return $value->webcollection_id === $webCollectionId;
                })->first();
                return $translation;
            }else{
                return null;
            }


//            $translation = Translations_WebCollection::where('language', '=', $activeLanguage)
//                ->where('webcollection_id', '=', $webCollectionId)
//                ->where('deleted_at', '=', '0')
//                ->first();
//            return $translation;
        }else{
            return null;
        }
    }

    public static function getTranslationByWebCollection($webCollection){
        $activeLanguage = b2b()->activeLanguage();
        if(isset($activeLanguage) && isset($webCollection)){
            $webCollection->webCollectionTranslations();
        }
    }
}