PHP code example of sgpatil / orientdb-laravel-5

1. Go to this page and download the library: Download sgpatil/orientdb-laravel-5 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sgpatil / orientdb-laravel-5 example snippets


Sgpatil\Orientdb\OrientdbServiceProvider::class,

'default' => 'orientdb',

'default_nosql' => 'orientdb',

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

php artisan orient:make create_users_table

php artisan orient:make add_votes_to_users_table --table=users_votes

php artisan orient:make create_users_table --create=users

php artisan orient:migrate

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

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

$user = User::create(['name' => 'Some Name', 'email' => '[email protected]']);


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

$user = User::find(1);

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

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