<?php
namespace Claromentis\Core\ORM;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_5e30c4717ced36cff9e93e19" . "a5c576cc" => base64_decode("aXNfc3RyaW5" . "n"), "_ea8229a121285ee6" . "49a72fd880bac39b" => base64_decode("YXJyYXlfZmlsd" . "GVy"), "_31767d7a" . "d58e706db" . "f47b7a51a" . "0fe6c4" => base64_decode("Y291" . "bnQ="), "_a591754a8ddcdbda9c80f1db4d" . "911e14" => base64_decode("aXNfbn" . "VsbA=="), "_bb152d3d0f3a7af77c" . "042dab184b9545" => base64_decode("PQ" . "=="), "_ebff9d37a7bb577c57" . "bee4dd9f0e5fd7" => base64_decode("YXJyYXlfdmFsd" . "WVz"));
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"]["_bb152d3d0f3a7af" . "77c042dab184b954" . "5"], $id)->exists();
    }
    
    
    
    
    
    
    
    public function findOrNew(int $id)
    {
        return $this->find($id) ?: $this->newInstance();
    }
    
    
    
    
    
    
    
    
    
    public function findOrFail($id, $_a42c86642011ef739b88ee80672c387d = ['*'])
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_a591754a8ddcdbda9c80f1db4d911e" . "14"]($_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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_ebff9d37a7bb577c57bee4dd9f0e5fd" . "7"]($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_ea8229a121285ee649a72fd880bac3" . "9b"]($_7363ddf39ba18000984e7bb4172393d8, function ($_79678d67f69838a075525f7021c8d213) {
            return $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_5e30c4717ced36cff9" . "e93e19a5c576cc"]($_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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_bb152d3d0f3a7af77c042dab184b954" . "5"], $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_31767d7ad58e706dbf4" . "7b7a51a0fe6c4"]($_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();
    }
}