You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi, it is possible to support merging two relation BelongsToMany and hasMany and returning relation laravel.
I need to merge two relationships (take and merge records from one table using different relationships...) and return the relationship in order to be able to perform actions with them... and then the method ->paginate($perPage, ['*'], 'page', $pageCurrent);
For example
There are item and seller models
seller.php
public function items()
{
return $this->belongsToMany(Item::class, 'item_seller', 'seller_id', 'item_id')->withPivot('id', 'enabled');
}
public function myItems()
{
return $this->hasMany(Item::class, 'seller_id');
}
I need to combine these two relations and return something similar
public function ALL_items_merged()
{
return $this->myItems() + $this-> items()
}
$seller->ALL_items_merged()
for further work with this relationship
Thanks for any tips or solutions
The text was updated successfully, but these errors were encountered:
hi, it is possible to support merging two relation BelongsToMany and hasMany and returning relation laravel.
I need to merge two relationships (take and merge records from one table using different relationships...) and return the relationship in order to be able to perform actions with them... and then the method ->paginate($perPage, ['*'], 'page', $pageCurrent);
For example
There are item and seller models
seller.php
I need to combine these two relations and return something similar
$seller->ALL_items_merged()
for further work with this relationship
Thanks for any tips or solutions
The text was updated successfully, but these errors were encountered: