2017 © Pedro Peláez
 

library orientdb-laravel-5

Laravel Orientdb Driver

image

pin-cnx/orientdb-laravel-5

Laravel Orientdb Driver

  • Tuesday, March 8, 2016
  • by pin-cnx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 15 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Orientdb Driver for Laravel 5

Orientdb Graph Eloquent Driver for Laravel 5, (*1)

Quick Reference

Requirements

  • Laravel 5.1 or above
  • Orientdb Server 2.1 or above

Installation

Add the package to your composer.json and run composer update., (*2)

{
    "require": {
        "sgpatil/orientdb-laravel-5": "dev-master"
    }
}

Add the service provider in config/app.php:, (*3)

Sgpatil\Orientdb\OrientdbServiceProvider::class,

This will register all the required classes for this package., (*4)

Database Configuration

Open config/database.php make orientdb your default connection:, (*5)

'default' => 'orientdb',
'default_nosql' => 'orientdb', //optional if you are using orientdb as a secondary connection

Add the connection defaults:, (*6)

'connections' => [
    'orientdb' => [
        'driver' => 'orientdb',
        'host'   => 'localhost',
        'port'   => '2480',
        'database' => 'database_name',
        'username' => 'root',
        'password' => 'root'
    ]
]

Add your database username and password in 'username' and 'password' field. In 'database_name' add name of orientdb database which you want to connect and use., (*7)

Migration

To create a migration, you may use the orient command on the Artisan CLI:, (*8)

php artisan orient:make create_users_table

The migration will be placed in your database/migrations folder, and will contain a timestamp which allows the framework to determine the order of the migrations., (*9)

The --table and --create options may also be used to indicate the name of the table, and whether the migration will be creating a new table:, (*10)

php artisan orient:make add_votes_to_users_table --table=users_votes

php artisan orient:make create_users_table --create=users

To run migration, (*11)

php artisan orient:migrate

How to Use

// To insert a record
class User extends \Orientdb {

    protected $fillable = ['name', 'email'];
}

$user = User::create(['name' => 'Some Name', 'email' => 'some@email.com']);

You can use this by extending Orientdb into model class., (*12)

To fetch all records, (*13)

$users = User::all();
foreach($users as $user){
        echo $user->id;
        echo $user->name;
        echo $user->email;
    }

To find a record, (*14)

$user = User::find(1);

To update a record, (*15)

$user = User::find(1);
$user->name = "New Name";
$user->save();

Relationships

To create one-to-one relationship, (*16)

$user =   User::create(['name'=>"Sumit", 'email' => "demo@email.com"]); // Create User node
$phone = new Phone(['code' => 963, 'number' => '98555533']); // Create Phone node
$relation = $user->has_phone()->save($phone); // Creating relationship

Unable to find has_phone() method ? See full example., (*17)

Want to learn more? See the wiki., (*18)

The Versions

08/03 2016

dev-master

9999999-dev

Laravel Orientdb Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sumit Patil

29/10 2015

dev-dev

dev-dev

Laravel Orientdb Driver

  Sources   Download

MIT

The Requires

 

by Sumit Patil