Hi all, I'm facing is a strange behaviour I want to share with you. I have two models linked one to another by a relationship: OrderItem has many Confirms. Inside an OrderItem model method I create two Confirms and I save them. Then I use
$confirms = $orderItem->getConfirms();
and $confirm it’s empty But if I use:
$confirms = Confirm::findByOrderItemId($orderItem->getId());
$confirms
is populated as I did. As a matter of facts if I see on the DB table Confirm I find the confirms even when I use the relationship alias function.
Is it a bug? Is it a known behaviour?
What am I missing about?
That’s the OrderItem relationship definition:
public function initialize(){
$this->setSource("OrderItem");
$this->hasMany(
'id',
'App\Models\Confirm',
'orderItemId',
[
'alias' => 'confirms',
'reusable' => true
]);
}