Closed azaharalam closed 11 months ago
Hi @azaharalam,
Try this relationship:
class DeliverySchedule extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function orders()
{
return $this->hasManyDeep(
Order::class,
[DeliveryItem::class, Transaction::class, OrderVehicle:class],
['delivery_schedule_id', 'id', 'id', 'id'],
['id', 'transaction_id', 'order_vehicle_id', 'order_id']
);
}
}
hi @staudenmeir thank you. it worked for me.
While defining relationships between tables, I encountered a challenge in establishing a direct relationship between tables.
The table structure is as follows:
DeliverySchedule(id) DeliveryItem(id, delivery_schedule_id, transaction_id) Transaction(id, order_vehicle_id) OrderVehicle(id, order_id) Order(id) The relationships are defined as follows:
A DeliverySchedule can have more than one DeliveryItem. DeliveryItem belongs to Transaction. Transaction belongs to OrderVehicle. OrderVehicle belongs to Order. I am specifically struggling with creating a direct relationship between DeliverySchedule and Order, as a DeliverySchedule can have more than one Order.
I am reaching out to seek your expert advice and guidance on whether it is possible to achieve this using Laravel's package. Any suggestions or insights you can provide would be immensely beneficial for my project.
Thank you for your time and consideration. I appreciate your assistance.