<?php

namespace Hilco\Models;

trait HasWebSiloOverrides {
    public function webSiloOverrides() {
        return $this
            ->morphMany(WebSiloOverride::class, 'overrideable', 'overrideable_type', 'overrideable_id')
        ;
    }

    public function webSiloOverride() {
        return $this
            ->morphOne(WebSiloOverride::class, 'overrideable', 'overrideable_type', 'overrideable_id')
            ->where('websilo_id', '=', b2b()->activeWebSilo()->id)
            ->where('language_code', '=', b2b()->activeLanguage())
        ;
    }
}