In OrientDB community-2.0 I created 2 classes countries and cities with relation hasOne through Has property. The related record creates and relation exists. However I can't retrieve related record neother from Country model nor from City. Instead I get following error in Tinker log: Array to string conversion
Tinker log:
☁ laravel php artisan tinker
Psy Shell v0.5.2 (PHP 5.5.20 — cli) by Justin Hileman
>>> $country = App\Country::create(['id' => 100, 'name' => 'Cyprus']);
=> App\Country {#776
id: "#13:0",
name: "Cyprus",
updated_at: "2015-11-01 13:09:35",
created_at: "2015-11-01 13:09:35",
}
>>> $city = new App\City(['id' => 10, 'name' => 'Limassol']);
=> App\City {#789
id: 10,
name: "Limassol",
}
>>> $relation = $country->has_city()->save($city);
=> Sgpatil\Orientdb\Eloquent\Edges\EdgeOut {#797}
>>> $city;
=> App\City {#789
id: "#14:0",
name: "Limassol",
Has: "#13:0",
updated_at: "2015-11-01 13:09:46",
created_at: "2015-11-01 13:09:46",
}
>>> $city->country;
PHP error: Array to string conversion in /Users/dalamar/Documents/projects/orient/laravel/vendor/laravel/framework/src/Illuminate/Database/Grammar.php on line 39
>>> $country;
=> App\Country {#776
id: "#13:0",
name: "Cyprus",
updated_at: "2015-11-01 13:09:35",
created_at: "2015-11-01 13:09:35",
}
>>> $country->cities;
PHP error: Array to string conversion in /Users/dalamar/Documents/projects/orient/laravel/vendor/laravel/framework/src/Illuminate/Database/Grammar.php on line 39
>>> $country->has_city;
PHP error: Array to string conversion in /Users/dalamar/Documents/projects/orient/laravel/vendor/laravel/framework/src/Illuminate/Database/Grammar.php on line 39
My models classes code:
Country
<?php
namespace App;
use Sgpatil\Orientdb\Eloquent\Model;
class Country extends Model
{
protected $guarded = [];
public function cities()
{
return $this->hasMany('App\City', 'Has');
}
public function has_city()
{
return $this->hasOne('App\City', 'Has');
}
}
City
<?php
namespace App;
use Sgpatil\Orientdb\Eloquent\Model;
class City extends Model
{
protected $guarded = [];
public function country()
{
return $this->belongsTo('App\Country', 'Has');
}
}
In OrientDB community-2.0 I created 2 classes countries and cities with relation hasOne through Has property. The related record creates and relation exists. However I can't retrieve related record neother from Country model nor from City. Instead I get following error in Tinker log: Array to string conversion
Tinker log:
My models classes code:
Country
City