dev-master
9999999-devLaravel Orientdb Driver
MIT
The Requires
The Development Requires
by Sumit Patil
dev-dev
dev-devLaravel Orientdb Driver
MIT
The Requires
by Sumit Patil
Wallogit.com
2017 © Pedro Peláez
Laravel Orientdb Driver
Orientdb Graph Eloquent Driver for Laravel 5, (*1)
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)
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)
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
// 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();
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)
Laravel Orientdb Driver
MIT
Laravel Orientdb Driver
MIT