Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

makss_87's avatar

Soft deleting works weird on server

Hello everyone! i'm using soft deletes for my models, and in some cases i'm quering deleted models via relations like this

   public function team()
    {
        return $this->belongsTo(Team::class)->withTrashed();
    }

The problem is that on my local env(laravel homestead) everything is fine but this relation returns null on hosting.

when i try to debug sql queries local version looks like this

select * from `teams` where `teams`.`id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

server version looks like this

select * from `teams` where `teams`.`id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `teams`.`deleted_at` is null
0 likes
0 replies

Please or to participate in this conversation.