Closed dkulyk closed 8 years ago
Can you be clearer at this point please?
Do yo mean to work with raw queries / query builder instead?
Eloquent uses lazy loading relationships, so it is possible to establish a relationship with EAV
class Client2 extends Model
{
use Propertier;
protected $table = 'clients';
public function parent()
{
return $this->belongsTo(Client2::class, 'parent_id');
}
}
parent_id
is property.
$client = Client2::query()
->with('properties')
->with('parent')
->first();
Result:
array:4 [
"id" => 1
"parent_id" => 2
"parent" => array:3 [
"id" => 2
"parent_id" => null
]
]
I do not really understand this. Could you try to explain it in other way?
On Tuesday, 2 February 2016, Dmytro Kulyk notifications@github.com wrote:
It uses lazy loading relationships, so it is possible to establish a relationship with EAV
class Client2 extends Model{ use Propertier; protected $table = 'clients'; public function parent() { return $this->belongsTo(Client2::class, 'parent_id'); }}
parent_id is property.
$client = Client2::query() ->with('properties') ->with('parent') ->first();
Result:
array:4 [ "id" => 1 "parent_id" => 2 "parent" => array:3 [ "id" => 2 "test" => [] "parent_id" => null ] ]
— Reply to this email directly or view it on GitHub https://github.com/IsraelOrtuno/Propertier/issues/18#issuecomment-178701870 .
Un saludo Israel Ortuño
EAV property is used as a key to relationships. It works. Do not do anything.
It is necessary to check the value of relationships through EAV