<?php
namespace Claromentis\Core\ORM;

$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_ea8229a" . "121285ee" . "649a72fd" . "880bac39" . "b" => base64_decode("YXJyYXlfZmls" . "dGVy"), "_bb152d3d0f3a7af77c042" . "dab184b9545" => base64_decode("PQ=" . "="), "_5e30c4717ced36cff9" . "e93e19a5c576cc" => base64_decode("aXNfc3RyaW" . "5n"), "_a591754a" . "8ddcdbda9" . "c80f1db4d" . "911e14" => base64_decode("aXNfb" . "nVsbA" . "=="), "_ebff9d37a7bb577c57bee4d" . "d9f0e5fd7" => base64_decode("YXJyYX" . "lfdmFs" . "dWVz"), "_31767d7a" . "d58e706db" . "f47b7a51a" . "0fe6c4" => base64_decode("Y291" . "bnQ="));
use Analogue\ORM\Drivers\IlluminateQueryBuilder;
use Analogue\ORM\EntityCollection;
use Analogue\ORM\EntityMap;
use Analogue\ORM\Mappable;
use Analogue\ORM\Repository as AnalogueRepository;
use Analogue\ORM\System\Mapper as AnalogueMapper;
use Analogue\ORM\System\Query;
use Claromentis\Core\ORM\Exceptions\EntityNotFoundException;




class Repository extends AnalogueRepository
{
    
    
    
    
    protected $mapper;
    
    
    
    
    
    
    
    
    public function __construct($_dabd1eb8030f2c29327a192cddfd85a9, $_7bf14ccb9bebab3964c83c16c77505c6 = null)
    {
        if (!$_dabd1eb8030f2c29327a192cddfd85a9 instanceof Mapper && $_dabd1eb8030f2c29327a192cddfd85a9 instanceof AnalogueMapper) {
            $_dabd1eb8030f2c29327a192cddfd85a9 = new Mapper($_dabd1eb8030f2c29327a192cddfd85a9);
        }
        parent::__construct($_dabd1eb8030f2c29327a192cddfd85a9, $_7bf14ccb9bebab3964c83c16c77505c6);
    }
    
    
    
    
    
    
    public function newInstance()
    {
        return $this->mapper->newInstance();
    }
    
    
    
    
    
    
    
    
    
    public function find($id)
    {
        return parent::find($id);
    }
    
    
    
    
    
    
    
    public function entityExists($id) : bool
    {
        $_09b016526a9df52fb2fdd56fa1d9e520 = $this->mapper->getEntityMap()->getKeyName();
        return $this->mapper->getQuery()->getQuery()->where($_09b016526a9df52fb2fdd56fa1d9e520, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_bb152d3d0f3a7af77c042" . "dab184b9545"], $id)->exists();
    }
    
    
    
    
    
    
    
    public function findOrNew(int $id)
    {
        return $this->find($id) ?: $this->newInstance();
    }
    
    
    
    
    
    
    
    
    
    public function findOrFail($id, $_a42c86642011ef739b88ee80672c387d = ['*'])
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_a591754a8ddcdbda9c80f" . "1db4d911e14"]($_ba1f6e266e3ebd29f620349be8ec92a5 = $this->mapper->find($id, $_a42c86642011ef739b88ee80672c387d))) {
            return $_ba1f6e266e3ebd29f620349be8ec92a5;
        }
        throw (new EntityNotFoundException())->setEntity($this->mapper->getEntityMap()->getClass());
    }
    
    
    
    
    
    
    
    
    
    
    public function findWith($id, $_7363ddf39ba18000984e7bb4172393d8 = [])
    {
        $_7363ddf39ba18000984e7bb4172393d8 = (array) $_7363ddf39ba18000984e7bb4172393d8;
        $_7363ddf39ba18000984e7bb4172393d8 = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_ebff9d37a7bb577c57bee4dd9f0e5" . "fd7"]($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_ea8229a121285e" . "e649a72fd880bac" . "39b"]($_7363ddf39ba18000984e7bb4172393d8, function ($_79678d67f69838a075525f7021c8d213) {
            return $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_5e30c4717ced36" . "cff9e93e19a5c57" . "6cc"]($_79678d67f69838a075525f7021c8d213);
        }));
        return $this->mapper->query()->with($_7363ddf39ba18000984e7bb4172393d8)->find($id);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function query()
    {
        return $this->mapper->getQuery()->getQuery();
    }
    
    
    
    
    
    
    
    
    
    protected function whereHasIn(Query $_7f5aa4e96d4b415a86ed72ebff677cbe, string $_79678d67f69838a075525f7021c8d213, array $_9cee5807b5bab08d25cd4213e63cb764) : Query
    {
        return $_7f5aa4e96d4b415a86ed72ebff677cbe->whereHas($_79678d67f69838a075525f7021c8d213, function (Query $_7f5aa4e96d4b415a86ed72ebff677cbe) use($_9cee5807b5bab08d25cd4213e63cb764) {
            $key = $_7f5aa4e96d4b415a86ed72ebff677cbe->getMapper()->getEntityMap()->getQualifiedKeyName();
            $_7f5aa4e96d4b415a86ed72ebff677cbe->whereIn($key, $_9cee5807b5bab08d25cd4213e63cb764);
        });
    }
    
    
    
    
    
    
    
    
    
    protected function whereHasAllIn(Query $_7f5aa4e96d4b415a86ed72ebff677cbe, string $_79678d67f69838a075525f7021c8d213, array $_9cee5807b5bab08d25cd4213e63cb764) : Query
    {
        return $_7f5aa4e96d4b415a86ed72ebff677cbe->whereHas($_79678d67f69838a075525f7021c8d213, function (Query $_7f5aa4e96d4b415a86ed72ebff677cbe) use($_9cee5807b5bab08d25cd4213e63cb764) {
            $key = $_7f5aa4e96d4b415a86ed72ebff677cbe->getMapper()->getEntityMap()->getQualifiedKeyName();
            $_7f5aa4e96d4b415a86ed72ebff677cbe->whereIn($key, $_9cee5807b5bab08d25cd4213e63cb764);
        }, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_bb152d3d" . "0f3a7af77" . "c042dab18" . "4b9545"], $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_31767d7ad58e706dbf47b7" . "a51a0fe6c4"]($_9cee5807b5bab08d25cd4213e63cb764));
    }
    
    
    
    
    
    
    
    protected function getColumnName(string $_3ab4cb54392757321b19c0165e9e4203) : string
    {
        return $this->mapper->getColumnName($_3ab4cb54392757321b19c0165e9e4203);
    }
    
    
    
    
    
    
    
    
    
    protected function getColumnNames(array $attributes) : array
    {
        return $this->mapper->getColumnNames($attributes);
    }
    
    
    
    
    
    
    
    public function getAttributeName(string $_16e904583014a98ae3677f33f097518d) : string
    {
        return $this->mapper->getAttributeName($_16e904583014a98ae3677f33f097518d);
    }
    
    
    
    
    
    
    
    
    
    protected function getAttributeNames(array $_a42c86642011ef739b88ee80672c387d) : array
    {
        return $this->mapper->getAttributeNames($_a42c86642011ef739b88ee80672c387d);
    }
    
    
    
    
    
    
    public function clearCache()
    {
        $this->mapper->clearCache();
    }
}