<?php
namespace Claromentis\Core\ORM;

$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] ?: array()) + array("_ea8229a121285ee649a72fd88" . "0bac39b" => base64_decode("YXJyYXlfZm" . "lsdGVy"), "_ebff9d37a7bb577c57b" . "ee4dd9f0e5fd7" => base64_decode("YXJyYX" . "lfdmFs" . "dWVz"), "_5e30c4717c" . "ed36cff9e93" . "e19a5c576cc" => base64_decode("aXNf" . "c3Ry" . "aW5n"), "_bb152d3d0f3a" . "7af77c042dab1" . "84b9545" => base64_decode("P" . "Q" . "=" . "="), "_31767d7ad5" . "8e706dbf47b" . "7a51a0fe6c4" => base64_decode("Y29" . "1bn" . "Q="), "_a591754a8ddc" . "dbda9c80f1db4" . "d911e14" => base64_decode("aXN" . "fbn" . "Vsb" . "A=="));
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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_bb152d3d0" . "f3a7af77c0" . "42dab184b9" . "545"], $id)->exists();
    }
    
    
    
    
    
    
    
    public function findOrNew(int $id)
    {
        return $this->find($id) ?: $this->newInstance();
    }
    
    
    
    
    
    
    
    
    
    public function findOrFail($id, $_a42c86642011ef739b88ee80672c387d = ['*'])
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_a591754a8ddcdb" . "da9c80f1db4d911" . "e14"]($_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["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_ebff9d37a7bb577c57b" . "ee4dd9f0e5fd7"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_ea8229a121285ee649a72fd880bac3" . "9b"]($_7363ddf39ba18000984e7bb4172393d8, function ($_79678d67f69838a075525f7021c8d213) {
            return $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_5e30c4717ced36cff9e93e" . "19a5c576cc"]($_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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_bb152d3d0f3a7af77c0" . "42dab184b9545"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_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();
    }
}