#Soft deleted models appearing when loading relation

3 messages · Page 1 of 1 (latest)

harsh oasis
#

I am trying to load with conditions a putaways relation on inventories collection but the following code is including the soft deleted Putaway models.

Is this a normal behaviour ?

$inventories->load([
  'putaways' => function (HasMany $putawayRelationQuery) {
    $putawayRelationQuery
      ->whereNull('deleted_at') // I have to add this line to exclude the soft deleted putaways
      ->where('status', 'done');
  },
]);
muted comet
#

Hello, is your putways model using the SoftDeletes trait?

harsh oasis
#

@muted comet yes it does.