-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
// \App\Models\User
class User extends \Corcel\Model\User {
use \Corcel\WooCommerce\Traits\HasRelationsThroughMeta;
public function products()
{
return $this
->hasManyThroughMeta(\Corcel\WooCommerce\Model\Product::class, 'prod_users', 'post_ID', 'ID')
->doesntHave('items');
}
}Calling $user->products, the NOT EXISTS sql clause queries the table wppl_woocommerce_order_items instead of wppl_woocommerce_order_itemmeta, generating this error: https://flareapp.io/share/Bm0BLkJ7#F73
This my current workaround to get everything work correctly:
// \App\Models\Corcel\Item
class Item extends \Corcel\WooCommerce\Model\Item
{
protected $table = 'woocommerce_order_itemmeta';
}
// \App\Models\Corcel\Product
class Product extends \Corcel\WooCommerce\Model\Product
{
public function items(): HasMany
{
return $this->hasManyThroughMeta(Item::class, '_product_id', 'order_item_id', 'order_item_id');
}
}
// \App\Models\User
class User extends \Corcel\Model\User {
use \Corcel\WooCommerce\Traits\HasRelationsThroughMeta;
public function products()
{
return $this
->hasManyThroughMeta(\App\Models\Corcel\Product::class, 'prod_users', 'post_ID', 'ID')
->doesntHave('items');
}
}Is this a bug or am I just not understanding something?
I need to build the relationship to get only products, never purchased, related to a specific user via meta prod_users.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels