You just have to add ->withTrashed() to your query.
$employees = Employee::withTrashed()->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am new to Laravel and I don't know should I do using eloquent. I have three tables employees, position and division. I'd like to hide employee or employees either division or position that assigned to them was soft deleted. Any suggestions? Can someone convert my query to eloquent.
Employee Model: public function position() { return $this->belongsTo(Position::class); }
public function division()
{
return $this->belongsTo(Division::class);
}
Here's my query: $employees = Employee::with('division', 'position', 'role')->where('status', '!=', 'Deleted')->orderBy('last_name', 'asc')->get();
SELECT first_name, last_name, title, p.deleted_at AS deleted_position FROM employees e LEFT JOIN employee_positions p ON e.position_id = p.id WHERE p.deleted_at IS NULL;
Please or to participate in this conversation.