<?php
namespace Claromentis\Core\ORM;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_5e30c4717ced36cff" . "9e93e19a5c576cc" => base64_decode("aXNf" . "c3Ry" . "aW5n"), "_ea8229a121285ee649a" . "72fd880bac39b" => base64_decode("YXJyYX" . "lfZmls" . "dGVy"), "_bb152d3d0f3a7af77c042dab18" . "4b9545" => base64_decode("P" . "Q" . "=" . "="), "_ebff9d37a7bb577c57bee4dd9f0e" . "5fd7" => base64_decode("YXJyY" . "Xlfdm" . "FsdWV" . "z"), "_a591754a" . "8ddcdbda9" . "c80f1db4d" . "911e14" => base64_decode("aXNf" . "bnVs" . "bA=="), "_31767d7ad5" . "8e706dbf47b" . "7a51a0fe6c4" => 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["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_bb152d3d0f3a7af7" . "7c042dab184b9545"], $id)->exists();
    }
    
    
    
    
    
    
    
    public function findOrNew(int $id)
    {
        return $this->find($id) ?: $this->newInstance();
    }
    
    
    
    
    
    
    
    
    
    public function findOrFail($id, $_a42c86642011ef739b88ee80672c387d = ['*'])
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_a591754a8ddcdbda9c80f1d" . "b4d911e14"]($_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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_ebff9d37a7bb577c" . "57bee4dd9f0e5fd7"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_ea8229a12" . "1285ee649a" . "72fd880bac" . "39b"]($_7363ddf39ba18000984e7bb4172393d8, function ($_79678d67f69838a075525f7021c8d213) {
            return $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_5e30c4717ced36cff9e93e19a5c576" . "cc"]($_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["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_bb152d3" . "d0f3a7af" . "77c042da" . "b184b954" . "5"], $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_31767d7ad58e706dbf47b7a51a0fe6c" . "4"]($_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();
    }
}