/**
  * Create a new query builder instance.
  *
  * @param Vinelab\NeoEloquent\Connection $connection
  * @return void
  */
 public function __construct(Connection $connection, Grammar $grammar)
 {
     $this->grammar = $grammar;
     $this->grammar->setQuery($this);
     $this->connection = $connection;
     $this->client = $connection->getClient();
 }
示例#2
0
 /**
  * Create a new delegate instance.
  *
  * @param \Vinelab\NeoEloquent\Eloquent\Builder $query
  * @param \Vinelab\NeoEloquent\Eloquent\Model   $parent
  */
 public function __construct(Builder $query)
 {
     $this->query = $query;
     $model = $query->getModel();
     // Setup the database connection and client.
     $this->connection = $model->getConnection();
     $this->client = $this->connection->getClient();
 }
示例#3
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     Auth::extend('simple', function ($app) {
         $model = config('auth.model');
         return new UserProvider(new $model());
     });
     $this->app['db']->extend('neo4j', function ($config) {
         $conn = new Connection($config);
         $conn->setSchemaGrammar(new CypherGrammar());
         $conn->setQueryGrammar(new AppCypherGrammar());
         return $conn;
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['db']->extend('neo4j', function ($config) {
         $conn = new Connection($config);
         $conn->setSchemaGrammar(new CypherGrammar());
         return $conn;
     });
     $this->app->booting(function () {
         $loader = \Illuminate\Foundation\AliasLoader::getInstance();
         $loader->alias('NeoEloquent', 'Vinelab\\NeoEloquent\\Eloquent\\Model');
         $loader->alias('Neo4jSchema', 'Vinelab\\NeoEloquent\\Facade\\Neo4jSchema');
     });
     $this->registerComponents();
 }
 public function updateLabels($labels, $operation = 'add')
 {
     $cypher = $this->grammar->compileUpdateLabels($this, $labels, $operation);
     $updated = $this->connection->update($cypher, $this->getBindings());
     return isset($updated[0]) && isset($updated[0][0]) ? $updated[0][0] : 0;
 }
示例#6
0
 /**
  * Set the table prefix and return the grammar.
  *
  * @param \Illuminate\Database\Grammar $grammar
  * @return \Illuminate\Database\Grammar 
  * @static 
  */
 public static function withTablePrefix($grammar)
 {
     //Method inherited from \Illuminate\Database\Connection
     return \Vinelab\NeoEloquent\Connection::withTablePrefix($grammar);
 }
示例#7
0
 /**
  * Run the query as a "select" statement against the connection.
  *
  * @return array
  */
 protected function runSelect()
 {
     return $this->connection->select($this->toCypher(), $this->getBindings());
 }