Well, the connection table is still required. It would just more transparent to me working with the models, handled silently by the ORM. With the previous example, to define the relation in eloquent, you would add one simple function to the model.
Reseller model:
public function products() {
return $this->hasMany('Product', 'reseller_products', 'reseller_id', 'product_id');
}
Product Model:
public function resellers() {
return $this->hasMany('Reseller', 'reseller_products', 'product_id', 'reseller_id');
}
And then retrieving / adding new items would be as simple as:
$reseller = Reseller::find(1);
$res_products = $reseller->products;
$product = new Product();
$product->name = 'demo';
$reseller->products->attach($product);
Perhaps I am just a little spoiled with the convenience.
It is not that big of a deal that I have to run an extra query to get the second table, or have to create the pivot manually. I just thought there would be something similar for xpdo.
For example,
<?xml version="1.0" encoding="UTF-8"?>
<model package="resellers" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.0">
<object class="Reseller" table="resellers" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
<otherrelation alias="Products" class="Product" local="reseller_id" foreign="product_id" pivot="ResellerProduct" cardinality="many" owner="local"/>
</object>
<object class="Product" table="products" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
<otherrelation alias="Resellers" class="Reseller" local="product_id" foreign="reseller_id" pivot="ResellerProduct" cardinality="many" owner="local"/>
</object>
<object class="ResellerProduct" table="reseller_product" extends="xPDOObject">
<field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
<field key="reseller_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
<field key="product_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
<!-- no relation needed -->
</object>
</model>
Just seen your reference to getObjectGraph. Had not seen that before, that certainly helps.
The performance loss of having to run multiple queries was another concern.
Still wondering how I could nest a grid of products within my form tab, though. If you get what I am trying to achieve
(I already owe you a couple beers)