<?php
namespace Claromentis\Core\ORM;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] ?: array()) + array("_bb152d3d0f" . "3a7af77c042" . "dab184b9545" => base64_decode("PQ" . "=="), "_31767d7ad58e706" . "dbf47b7a51a0fe6c" . "4" => base64_decode("Y291bn" . "Q="), "_ea8229a1" . "21285ee64" . "9a72fd880" . "bac39b" => base64_decode("YXJyYXlfZ" . "mlsdGVy"), "_a591754a8ddcdbda9c80f1db4d911e" . "14" => base64_decode("aXNfbnVsb" . "A=="), "_5e30c4717ced36cff9e93e19a5c576" . "cc" => base64_decode("aXNf" . "c3Ry" . "aW5n"), "_ebff9d37a7bb577c57bee4dd9" . "f0e5fd7" => base64_decode("YXJyYXlfd" . "mFsdWVz"));
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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_bb152d3d0f3a7af77" . "c042dab184b9545"], $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["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_ebff9d37a7bb577c57bee4d" . "d9f0e5fd7"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_ea8229a121285ee649a72fd" . "880bac39b"]($_7363ddf39ba18000984e7bb4172393d8, function ($_79678d67f69838a075525f7021c8d213) {
            return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_5e30c4717ced36cff9e9" . "3e19a5c576cc"]($_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["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_bb152d3d0f3a7" . "af77c042dab184" . "b9545"], $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_31767d7ad58e706dbf47b7a51a0" . "fe6c4"]($_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();
    }
}